home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / fortran / 4327 < prev    next >
Encoding:
Text File  |  1992-11-16  |  2.0 KB  |  71 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!gumby!wupost!dsuvax.dsu.edu!rolfe
  3. From: rolfe@dsuvax.dsu.edu (Tim Rolfe)
  4. Subject: Re: Print characters on one line without newline...???
  5. Message-ID: <1992Nov16.201614.14487@dsuvax.dsu.edu>
  6. Organization: Dakota State University
  7. References: <BxtnK6.23s@cs.uiuc.edu>
  8. Date: Mon, 16 Nov 1992 20:16:14 GMT
  9. Lines: 60
  10.  
  11. a.cs.uiuc.edu denies any knowledge of ctaylor, and gets major indigestion
  12. at the "sparc0b!ctaylor@cs.uiuc.edu" construction, so I guess I'll post my
  13. suggestion here.  Bandwidth apologies, etc.
  14.  
  15. In comp.lang.fortran you write:
  16.  
  17. >         I'm writting this PrintX routine that is to print
  18. >the letter X n times on one line without any spaces and
  19. >newline.  My PrintX routine looks like this:
  20.  
  21. >      SUBROUTINE PrintX(XCOUNT)
  22. >        INTEGER XCOUNT
  23.  
  24. >        INTEGER i
  25.  
  26. >        DO 10 i, XCOUNT
  27. >          PRINT 20
  28. >  10    CONTINUE
  29. >  20    FORMAT(1X, 'X')
  30.  
  31. >        PRINT *
  32. >        
  33. >        RETURN
  34. >        END
  35.  
  36. >correct: XXXXX...X
  37. >incorrect: X
  38. >           X
  39. >           X
  40. >           .
  41. >           .
  42. >           X
  43.  
  44.  
  45. I am only familiar with FORTRAN-77; under that I don't think there's a
  46. standard-conforming method to do EXACTLY what you're asking for.  Many
  47. implementers, though, have the formatting character "$" in their superset
  48. --- you may well want to check on the Fortran for your machine.
  49.  
  50. What's wrong, though, with building a character string and outputting THAT.
  51. Even better for the specimen code, though, would be using an implied
  52. DO-loop.
  53.  
  54.       SUBROUTINE PrintX(XCOUNT)
  55.       INTEGER XCOUNT
  56.       INTEGER i
  57.       if (XCOUNT .gt. 0) then
  58.          print 10, ('X', i = 1, XCOUNT)
  59.       else
  60.          print 10
  61.       end if
  62.    10 format (1x, 80a1)
  63. * I don't know if you intended the extra line or not:
  64. *?    print 10
  65.       return
  66.       end
  67. -- 
  68.                                               --- Tim Rolfe
  69.                                            rolfe@dsuvax.dsu.edu
  70.                                             ROLFE@SDNET.BITNET
  71.