Silverfrost Forums

Welcome to our forums

How do you use quoted syntax as invariables?

10 Nov 2014 11:27 #15023

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?

11 Nov 2014 8:31 #15029
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
11 Nov 2014 11:19 #15046

Thx a bunch 😄 lol sorry if I seem a bit transversed. I just started learning this stuff so I'll try to be a lot less extroverted. 😉

Please login to reply.