Path: utzoo!mnetor!uunet!husc6!bbn!uwmcsd1!marque!gryphon!crash!jeh From: jeh@crash.cts.com (Jamie Hanrahan) Newsgroups: comp.os.vms Subject: Re: FORTRAN DOUBLE SPACES PRINTED LINES WITH TABS Message-ID: <2714@crash.cts.com> Date: 22 Mar 88 23:44:45 GMT References: <8803211520.AA00743@ucbvax.Berkeley.EDU> Reply-To: jeh@crash.CTS.COM (Jamie Hanrahan) Organization: CMKRNL Press, San Diego, CA Lines: 52 Summary: Your output lines are wrapping. In article <8803211520.AA00743@ucbvax.Berkeley.EDU> writes: > OPEN(UNIT=1,TYPE='OLD',NAME=FILE,READONLY,CARRIAGECONTROL='LIST') > . > PRINT 20,LINE >20 FORMAT(1X,A80) > >If one of you could tell me why this inserts a CRLF after any line >containing a tab, I would be much obliged. > >Dan >graham@drcvax.arpa The trouble is that, after the carriage control byte (1X) is removed by the terminal driver, you're always sending 80 characters, regardless of the length of the record you get from the input file. When one (or more) of these is a tab, the cursor moves more than one column for one (or more) of those 80 characters, so the cursor moves right more than 80 columns; if the terminal is set to wraparound, it injects the CRLF. If you want to fix it in the "environment", turn the terminal's wraparound feature off, and do a SET TERM /NOWRAP . To fix it in the code, read your record with something like READ (lun, 10) LINE_LENGTH, LINE 10 FORMAT (Q, A) and write it with PRINT 20, LINE(1:LINE_LENGTH) 20 FORMAT (1X, A) The "Q" format code returns the "number of characters remaining to be transferred in an input record", so the integer variable LINE_LENGTH gets the actual record length. Then you write out just that substring, avoiding the trailing blanks that Fortran wants to give you. The "A" format code, used without a field-width specifier on a character variable or expression, defaults to the actual length of the expression. Uhhh... you'll probably have to do something like LINE_LENGTH = MAX (LINE_LENGTH, 1) to handle zero-length records, as Fortran abhors zero-length strings. BTW, the CARRIAGECONTROL="LIST" does absolutely nothing for you on input files, except possibly avoid a record attribute mismatch warning-level message. On output files to disk it merely specifies what value to store in the record attribute field in the file header, and has no effect on the data records written to disk. On output files to carriage-control devices like terminals and printers, it does what you think it will. So if instead of using PRINTs you WRITE your output to a lun opened with CARRIAGECONTROL= "LIST", you can get rid of the "1X" fortranism in your output formats.