LoginLogin

Multiple results using INPUT

Root / Programming Questions / [.]

ReddfairchildCreated:
Hey, guys. I'm attempting to make a text-based RPG, and I've encountered a problem when using INPUT. Here's my code. - @Page2 ?"Input 'NEXT" to go to page 3. Input 'PREV' to go to page 1." Input CMDLIST$ If "NEXT" then GOTO @Page3 if "PREV" then GOTO @Page1 GOTO @page2 @Page1 ACLS print"test" GOTO @page1 @Page3 ACLS print"test2" GOTO @page 3 - I'm trying to get two different responses depending on what I type, but I can't figure out how to do that. When I run the program, it doesn't matter what I put; it goes to the first @ command in the loop (which would be @page1) and as long as there is "GOTO @Page1" at the end of the loop, it ignores the code after it. I've only started using SmileBASIC a few days ago, so any advice is appreciated.

You need something to check in the IF statement:
If CMDLIST$=="NEXT" then GOTO @Page3
if CMDLIST$=="PREV" then GOTO @Page1

Oh, alright. Thanks for helping! ^^

When I run the program, it doesn't matter what I put; it goes to the first @ command in the loop (which would be @page1) and as long as there is "GOTO @Page1" at the end of the loop, it ignores the code after it.
This happens because the string you put as the condition always counts as the boolean value TRUE, which makes the IF statement come true. It's pretty complicated at first but become clearer after practices. I also noticed that your PRINT loops are pretty wonky. After the @ label, you should use CLS instead of ACLS because CLS is much faster. Also, add a VSYNC or WAIT at the end of the loop so the text doesn't look all flashy. So @Page3 ACLS print"test2" GOTO @page 3 would become @Page3 CLS print"test2" VSYNC 1 GOTO @page 3

When I run the program, it doesn't matter what I put; it goes to the first @ command in the loop (which would be @page1) and as long as there is "GOTO @Page1" at the end of the loop, it ignores the code after it.
This happens because the string you put as the condition always counts as the boolean value TRUE, which makes the IF statement come true. It's pretty complicated at first but become clearer after practices. I also noticed that your PRINT loops are pretty wonky. After the @ label, you should use CLS instead of ACLS because CLS is much faster. Also, add a VSYNC or WAIT at the end of the loop so the text doesn't look all flashy. So @Page3 ACLS print"test2" GOTO @page 3 would become @Page3 CLS print"test2" VSYNC 1 GOTO @page 3
Okay, I'll try that! I didn't understand why it was flashing like that, so thanks for pointing it out! :)