This is how I did it, back in QB. I checked for a space " ", then knew that one word was the verb, and the other was the object.
for i=0 to len(string$)
if mid$(string$,i,1)=" " then verb$=left$(string$,i):object$=right$(string$,len(string$)-i-1):break
next i
This'd give a verb$ and an object$. Then, you just loop through your array of stuff, and see if they match. Notice I'm using 3 types of variable; verb is an integer that holds the index of the verb, verb
$ is the verb that the user typed in, and verb
s$ is the array of verbs. Similarly for objects, except objpos() is an array showing where the object is.
dim verbs$(3)
data "look"
data "take"
data "drop"
dim objects$(2)
data "vase"
data "brick"
dim objpos(2)
rem Not bothering to read the data, to save typing.
for i=0 to 2
if verb$=verbs$(i) then verb=i
next i
for i=0 to 1
if object$=objects$(i) then object=i
next i
select case verb
case is = 0
rem Look
select case object
case is = 0
message$="It's a vase, very nice it is too."
end case
case is = 1
message$="It's a brick. You could lob it through a window."
end case
end select
if message$="" then message$="You don't see that here"
end case
case is = 1
rem Take
if object >= 0 and object <= 1 and objpos(object)=location
objpos(object)=-1
message$="Taken"
else
message$="You can't take that!"
endif
end case
case is = 2
rem Drop
if object >= 0 and object <= 1 and objpos(object)=-1
objpos(object)=location
message$="Dropped"
else
message$="You can't drop that!"
endif
end case
end select
If message$="" then message$="You make no sense."
Sorry about the code, it's a hybrid of DB, QB, VB and randomness that occurs in my head, and my formatting didn't work out properly. You should be able to work out what is happening though.
Once I was but the learner,
now, I am the Master.