Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WHAT IS WRONG WITH THIS SCRIPT?!?!
#1
Could someone please tell me what i'm doin wrong here!!
I type the following script in and then get the message 'Block IF without END IF' and cant run my script

THE SCRIPT:

INPUT "choice", mainmenu%
IF mainmenu% = 1 THEN
GOTO 1
IF mainmenu% = 2 THEN
GOTO 2
IF mainmenu% = 3 THEN
GOTO 3
IF mainmenu% = 4 THEN
GOTO 4
IF mainmenu% = 5 THEN
GOTO 5
IF mainmenu% = 6 THEN
GOTO 6
ELSE
GOTO 7
END IF

PLEASE HELP!!!!!!!!!!
Reply
#2
Easily Fixed:

Code:
INPUT "choice", mainmenu%
IF mainmenu% = 1 THEN
GOTO 1
END IF
IF mainmenu% = 2 THEN
GOTO 2
END IF
IF mainmenu% = 3 THEN
GOTO 3
END IF
IF mainmenu% = 4 THEN
GOTO 4
END IF
IF mainmenu% = 5 THEN
GOTO 5
END IF
IF mainmenu% = 6 THEN
GOTO 6
END IF

GOTO 7
LA BLA BLA
Reply
#3
Actually It'd be easier with this:

Code:
INPUT " Select number (1-6): ", number%

SELECT CASE number%
CASE "1"
GOTO 1
CASE "2"
GOTO 2
CASE "3"
GOTO 3
CASE "4"
GOTO 4
CASE "5"
GOTO 5
CASE "6"
GOTO 6
END SELECT
LA BLA BLA
Reply
#4
(if less typing is "easier"):

INPUT "choice", mainmenu%
IF mainmenu% = 1 THEN GOTO 1
IF mainmenu% = 2 THEN GOTO 2
IF mainmenu% = 3 THEN GOTO 3
IF mainmenu% = 4 THEN GOTO 4
IF mainmenu% = 5 THEN GOTO 5
IF mainmenu% = 6 THEN GOTO 6
GOTO 7
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#5
Code:
IF mainmenu% >= 1 THEN IF mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#6
Code:
IF mainmenu% >= 1 AND mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6
Tongue
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#7
I always thought it was quite an oversight not being able to branch directly on a variable value. Like GOTO a% or GOSUB a$

But I'm sure there's a good reason for it.. right Glenn?
In a world without walls and doors, who needs Windows and Gates?
Reply
#8
I'll tell you why.

When QB compiles, it converts all labels and line numbers to a program address. Doing GOTO a$ is impossible because there wouldn't exist any such thing when running the program. GOTO a%, however, is possible, if you include a range (say 0 to 5):
The compiler would just have to convert
GOTO a%(0 to 5) to:
ON a% GOTO 0, 1, 2, 3, 4, 5 .

But it doesn't.

EDIT: Of course, qb could have a feature that retains each label in strings in some section of the code, and the corresponding converted addresses. It wouldn't take up very much room. That way what you describe is possible and creates a more flexible language. But it doesn't do that.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#9
But if one didn't have to find workarounds for things people wish whatever compiler they're using could do that it can't explicitly do, well, 90% of the fun of programming would be gone. Smile (I'm not sure that 90% of programming, period, wouldn't be gone. Smile )

Quote:I always thought it was quite an oversight not being able to branch directly on a variable value. Like GOTO a% or GOSUB a$

But I'm sure there's a good reason for it.. right Glenn?
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#10
Glenn, Glenn! Did you read my post? There is a good reason!
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)