home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.fortran
- Path: sparky!uunet!gumby!wupost!dsuvax.dsu.edu!rolfe
- From: rolfe@dsuvax.dsu.edu (Tim Rolfe)
- Subject: Re: Print characters on one line without newline...???
- Message-ID: <1992Nov16.201614.14487@dsuvax.dsu.edu>
- Organization: Dakota State University
- References: <BxtnK6.23s@cs.uiuc.edu>
- Date: Mon, 16 Nov 1992 20:16:14 GMT
- Lines: 60
-
- a.cs.uiuc.edu denies any knowledge of ctaylor, and gets major indigestion
- at the "sparc0b!ctaylor@cs.uiuc.edu" construction, so I guess I'll post my
- suggestion here. Bandwidth apologies, etc.
-
- In comp.lang.fortran you write:
-
- > I'm writting this PrintX routine that is to print
- >the letter X n times on one line without any spaces and
- >newline. My PrintX routine looks like this:
-
- > SUBROUTINE PrintX(XCOUNT)
- > INTEGER XCOUNT
-
- > INTEGER i
-
- > DO 10 i, XCOUNT
- > PRINT 20
- > 10 CONTINUE
- > 20 FORMAT(1X, 'X')
-
- > PRINT *
- >
- > RETURN
- > END
-
- >correct: XXXXX...X
- >incorrect: X
- > X
- > X
- > .
- > .
- > X
-
-
- I am only familiar with FORTRAN-77; under that I don't think there's a
- standard-conforming method to do EXACTLY what you're asking for. Many
- implementers, though, have the formatting character "$" in their superset
- --- you may well want to check on the Fortran for your machine.
-
- What's wrong, though, with building a character string and outputting THAT.
- Even better for the specimen code, though, would be using an implied
- DO-loop.
-
- SUBROUTINE PrintX(XCOUNT)
- INTEGER XCOUNT
- INTEGER i
- if (XCOUNT .gt. 0) then
- print 10, ('X', i = 1, XCOUNT)
- else
- print 10
- end if
- 10 format (1x, 80a1)
- * I don't know if you intended the extra line or not:
- *? print 10
- return
- end
- --
- --- Tim Rolfe
- rolfe@dsuvax.dsu.edu
- ROLFE@SDNET.BITNET
-