Silverfrost Forums

Welcome to our forums

user input code

12 Nov 2014 8:39 #15053

Hi;

Does ftn95 have anything like the TrueBasic INPUT PROMPT statement?

It's used to ask the user to input a value and wait for a reply on the same line.

Tia,

Roger

12 Nov 2014 8:53 #15054
integer i,j
do
   write(*,'(A,$)')'Enter a number, 0 to quit: '
   read(*,*)i
   write(*,*)' you entered: ',i
   if(i.eq.0)exit
end do
write(*,*)' Program completed '
end program
12 Nov 2014 9:10 #15056

Ok, that works!

I understand the A format but what is $ doing to prevent a newline?

Thanks,

Roger

12 Nov 2014 10:22 #15058

The $ control descriptor (sometimes a backslash is used for the same purpose) is a non-standard but fairly common device created precisely to facilitate terminal I/O.

Remember, Fortran was widely used in the '60s, and CRT and teletype terminals were not much used by normal people (as opposed to sysadmins), so when CRT terminals became popular in the '70s, some means was needed to suppress the carriage return that normally came after a line of output.

See, e.g., http://publib.boulder.ibm.com/infocenter/comphelp/v101v121/index.jsp?topic=/com.ibm.xlf121.aix.doc/language_ref/cntrleditdesc.html

12 Nov 2014 10:33 #15059

Ok, thanks.

TrueBasic does it with a ; at the end of the write statement.

The $ means string variable to me.

Roger

Please login to reply.