[comp.os.vms] FORTRAN DOUBLE SPACING PROBLEM SOLVED + A CUTE PROGRAM

graham@DRCVAX.ARPA (03/22/88)

Greetings and Hallucinations,

Thank you's are in order to a dozen people who answered my query about 
why FORTRAN double spaces output if the output line contains a tab and the 
output format statement id a80.  

Well, it's not Fortran's fault, it's my stupidity.  Since the terminal is 
set to wrap and the format statement was A80, a tab eas translated by the 
terminal to eight spaces making the total line length more than 80.  I 
started using the Q operator in the read format statement to get the line 
length, then I used the <> construct in the output format statements and 
voila!  No double spacing.

The program was trivial, but cute.  It reads any text file with lines 
shorter than 80 characters backwards, i.e. last line forst, etc.  Since it 
is short, I include it here for the amusement of the net.

Thanks again to those who helped me see the problem.

Dan

........................................................................
	PROGRAM BACKWARDS

	INTEGER*2 COUNT,LENGTH
	CHARACTER*80 LINE
	CHARACTER*32 FILE
	CHARACTER*6 PROMPT/'File: '/

	CALL LIB$GET_FOREIGN(%DESCR(FILE),%DESCR(PROMPT))
	OPEN(UNIT=1,TYPE='OLD',NAME=FILE,READONLY,CARRIAGECONTROL='LIST')
	COUNT = 0
1	READ(1,20,END=2)LENGTH,LINE
	COUNT = COUNT + 1
	GOTO 1
2	BACKSPACE 1
	READ(1,20,ERR=999)LENGTH,LINE
	PRINT 25,LINE
	DO I=1,COUNT-1
	    BACKSPACE 1
	    BACKSPACE 1
	    READ(1,20,ERR=999)LENGTH,LINE
	    PRINT 25,LINE
	ENDDO

10	FORMAT(1X,'Filename: ',$)
15	FORMAT(A32)
20	FORMAT(Q,A)
25	FORMAT(X,A<LENGTH>)

999	END
------