Posts: 488
Threads: 19
Joined: Sep 2005
i'm working on a text rpg right now for fun, my 1st real project. anyways everything is based on menus, my problem is if i start running menus as routes from oterh menus, when i go back to the main menu, i acnt access an alrdy accessed menu, wats wrong, even just usin the input command on 1 menu selection makes the whole menu unaccessable from the main menu. can anyone maybe help me out??? or even supply a way to go from 1 menu to 4 others and still allow functions like input to work properly???
Posts: 1,956
Threads: 65
Joined: Jun 2003
It's hard to imagine what your problem is from your description. Could you post some code?
*****
Posts: 488
Threads: 19
Joined: Sep 2005
WHILE choice$ < "a" OR choice$ > "e"
CLS
PRINT "What would you like do do next?"
PRINT ""
PRINT "a. Stats"
PRINT "b. Inventory"
PRINT "c. Town"
PRINT "d. Battle"
PRINT "e. Quit"
INPUT choice$
IF choice$ = "a" THEN GOSUB Stats
IF choice$ = "a" THEN GOSUB Inventory
IF choice$ = "a" THEN GOSUB Town
IF choice$ = "a" THEN GOSUB Battle
IF choice$ = "a" THEN GOSUB Quit
choice$ = ""
Wend
That's the main menu, then the Town, Battle and Quit menu are pretty same thing just different variable and different text.
Problem: I run program, type "c", then press Enter, i select the Inn option from the Town sub menu, then when I'm done, i exit that menu, it returns me to main menu and then i can't select the Town menu, it freezes up or keeps reseting the main menu
Posts: 525
Threads: 23
Joined: Oct 2004
The problem is here:
WHILE choice$ < "a" OR choice$ > "e"
This should be
WHILE choice$ < "a" AND choice$ > "e"
What you want to accomplish is that the loop should exit when choice$ is a, b, c, d or e right?
The way you have it right now is at the end of the loop, before the wend, when you set choice$ to "" it's < "a" yes (so that part is true) however it's not bigger than "e" so it exits the loop because of that second part. with an OR...but with an AND it should work as expected.
Posts: 488
Threads: 19
Joined: Sep 2005
not sure y u chnged OR to AND, the main menu works fine up until i access a option wioth another INPUT command
Posts: 2,765
Threads: 138
Joined: Nov 2002
Code:
IF choice$ = "a" THEN GOSUB Stats
IF choice$ = "a" THEN GOSUB Inventory
IF choice$ = "a" THEN GOSUB Town
IF choice$ = "a" THEN GOSUB Battle
IF choice$ = "a" THEN GOSUB Quit
Dunno if you meant to put "a" for each of them..
but.. try this.
Code:
SELECT CASE choice$
CASE "a": GOSUB Stats
CASE "b": GOSUB Inventory
CASE "c": GOSUB Town
CASE "d": GOSUB Battle
CASE "e"; GOSUB Quit
END SELECT
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 488
Threads: 19
Joined: Sep 2005
i meant a,b,c,d,e
but anyway it does the same thing, doesnt it, anyway ill try it for fun l8er
Posts: 1,956
Threads: 65
Joined: Jun 2003
At the top of the menu, you should not test the variable choice$ before you ever read it.
Using WhiteTiger's suggestions, I'm changing your code as follows. Notice the changes. I hope you agree.
Code:
DO
CLS
PRINT "What would you like do do next?"
PRINT
PRINT "a. Stats"
PRINT "b. Inventory"
PRINT "c. Town"
PRINT "d. Battle"
PRINT "e. Quit"
INPUT choice$
choice$ = lcase$(left$(choice$,1))
SELECT CASE choice$
CASE "a": GOSUB Stats
CASE "b": GOSUB Inventory
CASE "c": GOSUB Town
CASE "d": GOSUB Battle
CASE "e": GOSUB Quit : SYSTEM
END SELECT
LOOP
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:but anyway it does the same thing, doesnt it
No I don't believe so. With yours it checks choice$ over and over again for each one. with SELECT CASE it's only once.
Plus it's easier to look at =P
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 719
Threads: 72
Joined: Mar 2003
your problem may be in the actual sub label
Code:
GOSUB test
print "completed sub `test`"
end
test:
print "moooooooooo"
return ' Magic of basic syntax - return to where GOSUB was called.
that may just be the problem
oz~