View previous topic :: View next topic |
Author |
Message |
Williams
Joined: 10 Nov 2014 Posts: 5
|
Posted: Tue Nov 11, 2014 12:27 am Post subject: How do you use quoted syntax as invariables? |
|
|
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 |
|
|
davidb
Joined: 17 Jul 2009 Posts: 560 Location: UK
|
Posted: Tue Nov 11, 2014 9:31 am Post subject: |
|
|
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 |
|
|
Williams
Joined: 10 Nov 2014 Posts: 5
|
Posted: Wed Nov 12, 2014 12:19 am Post subject: |
|
|
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. |
|
Back to top |
|
|
|