Here's some advice:
Doesn't upper$() make the whole string uppercase? i.e. upper$("hELlo ThEre") = "HELLO THERE"
With this you don't need to check your input twice.
To make the text input in real-time, you could have a huge select case statement which checks the scancode() and adds a letter for each keypress. Something like:
a#=scancode()
select a#
case 1
action$=action$+"q"
endcase
case 2
action$=action$+"w"
endcase
...
This could be quite tedious to input, plus you'd need to stop repeated keys, and also make it fast enough for fast typers not to have missing letters because they typed too fast. Just a suggestion.
I would go about a text game in a completely different way. I'd have a text parser which gets the words in my sentence and checks what the verbs and objects are (e.g. TAKE BOOK, verb$="TAKE", object$="BOOK". Then you'd have a big select case statement for verb$
select upper$(verb$)
case "GO"
some code to make the player location change
endcase
case "TAKE"
some code to put the object into inventory
endcase
...
and in each case you'd set responses for the appropriate objects and a default response (You don't see that here...) if no objects are selected. Last time I tried, you couldn't nest select case statements, I don't know if you can yet. If you can't, it means a lot of if statements to determine the object selected.
Then I would have several arrays. One contains the location descriptions, and one contains the directions you can go and destinations you can reach from that location. For example:
dim location$(100,1)
data "You are in a room"
data "You are somewhere else"
data "You are by a tree"
... etc
dim location_destinations(100,6)
data 2,53,-1,-1,-1,-1
data 5,-1,23,12,-1,15
data 6,1,-1,5,60,-1
... etc
rem location_destinations(i,0)=where you get to by going north
rem location_destinations(i,1)=where you get to by going east
rem location_destinations(i,2)=where... south
rem location_destinations(i,3)=where... west
rem location_destinations(i,4)=where... up
rem location_destinations(i,5)=where... down
rem destination of -1 means you can't go that way
...
do
Print location$(player_location)
some form of input
say that verb$="go" and object$="west"
if location_destination(player_location,3)=-1
print "You can't go that way"
else
player_location=location_destination(player_location,3)
endif
...
loop
You'd keep object descriptions and locations in other arrays like the location ones, except the object position would reference a location, -1 being in the inventory. Also, you'd want an array of flags to keep track of in-game events. They don't have to be in any order, as long as you know which one relates to which event. For example, flag(30) could be initially 0 and then change to 1 when you blow up a bridge.
select verb$
etc
if player_location=26 and flag(30)=1 then print "The bridge is destroyed! You can't go that way." else move the player
...
Is any of that useful to you?