forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

user input code

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
rogerh



Joined: 02 Nov 2014
Posts: 46
Location: Longmont, CO

PostPosted: Wed Nov 12, 2014 9:39 pm    Post subject: user input code Reply with quote

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
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Nov 12, 2014 9:53 pm    Post subject: Reply with quote

Code:
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
Back to top
View user's profile Send private message
rogerh



Joined: 02 Nov 2014
Posts: 46
Location: Longmont, CO

PostPosted: Wed Nov 12, 2014 10:10 pm    Post subject: Reply with quote

Ok, that works!

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

Thanks,

Roger
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Nov 12, 2014 11:22 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
rogerh



Joined: 02 Nov 2014
Posts: 46
Location: Longmont, CO

PostPosted: Wed Nov 12, 2014 11:33 pm    Post subject: Reply with quote

Ok, thanks.

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

The $ means string variable to me.

Roger
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group