Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Descriptor Portability

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
US
I have been searching and searching for a way to make a certain WRITE statement more portable...and I can't for the life of me figure it out!?!?!? Here's the problem code

WRITE(*,'("+",A,$)') 'HELLO'

How the Heck to I replace the "$" in the above??? I originally thought that "ADVANCE='NO'" would do it...but, that does not function exactly as "$" does. The "$" seems to reset the beginning of the line to the current column...the ADVANCE doesn't reset the beginning of the line, it just doesn't do a Carriage Return.

Any ideas will be most helpful!!!
 
Hi CJason

Could the problem be that you are combining "+" and $ in the format. Have you tried it without the "+" formatter, that actually writes over the last line that was written?
Try to put " " instead or skip it and use ' HELLO' (with a space before HELLO).

What is the next line in your program after that WRITE statement? ... and the line before?

PS: My old Microsoft compiler gave an error on "+", so that I had to use 1H+ instead, when I was testing this.

 
Using quotes for strings was only introduced recently. Have you tried
Code:
WRITE(*, 100) 'HELLO'
100 FORMAT ('+',A,$)
ADVANCE means Stay where you are: do not move. If you want a carriage return, print char(13)
Code:
      program carriage
      double precision xxx
      character*1 cr
      cr = char(13)
      xxx = 3.1415926535
      write (*,10, advance='no') 'Half a line'
10    format (A)
      write (*,20) ' Remainder', xxx
20    format (A, D15.10)
      write (*,30) 'Will be  wiped'
30    format (A, $)
      write (*,40) 'Will be s'
40    format (A)
      ! Same effect as $
      write (*,50, advance='no') 'Will be  wiped', cr
50    format (A,A)
      write (*,40) 'Wont be s'
      stop
      end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top