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 

How do you use quoted syntax as invariables?

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



Joined: 10 Nov 2014
Posts: 5

PostPosted: Tue Nov 11, 2014 12:27 am    Post subject: How do you use quoted syntax as invariables? Reply with quote

I've been trying to get a program to do a command line with a word that
takes you to another interface. The code looks like this

CHARACTER (LEN=20), PARAMETER :: command="goin"
READ (*,*) COMMAND

Of which I tried later

REAL (LEN=COMMAND) "goin"
READ (*,*) LEN

Now I've tried many ways of doing this. They don't work..Or they work
and they don't do it & they send an error message.
The program is supposed to look like this:

1 thing: (command here)
2 thing: (enter command)
3 thing: (go somewhere)
4 somewhere else: (syntax)

or on a more basic level

1 thing: (command here)
2 thing: (enter command)
3 thing: (correct or not correct, the keyword is [g][o][i][n])
4 thing: (error)
What I'm trying to get it to do is to do an error message when I don't
enter in the correct ascii/unicode symbols.
I know it works like this (g) (o) (i) (n) but I don't know how you
insert it into READ as I've been assuming that its an INTEGER LOGICAL.
Any suggestions?
Back to top
View user's profile Send private message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Tue Nov 11, 2014 9:31 am    Post subject: Reply with quote

Code:

program genie

   character(len=1000) :: command

   ! Get command string from user
   print *,' What is your command?'
   read(*,'(a)') command

   ! Act on command string
   if (trim(command) == 'tell me') then
      print *,'You have three wishes'
   else
      print *,'Goodbye'
   end if

end program genie

_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
Williams



Joined: 10 Nov 2014
Posts: 5

PostPosted: Wed Nov 12, 2014 12:19 am    Post subject: Reply with quote

Thx a bunch Very Happy lol sorry if I seem a bit transversed. I just started learning this stuff so I'll try to be a lot less extroverted. Wink
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 -> General 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