Posts: 11
Threads: 6
Joined: Jun 2003
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!!!!!!!!!!
Posts: 37
Threads: 8
Joined: May 2003
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
Posts: 37
Threads: 8
Joined: May 2003
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
Posts: 704
Threads: 0
Joined: Dec 2002
(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.
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 199
Threads: 2
Joined: May 2003
Code:
IF mainmenu% >= 1 AND mainmenu% <= 6 THEN ON mainmenu% GOTO 1, 2, 3, 4, 5, 6
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79]
[/url]
END OF LINE
.
Posts: 354
Threads: 11
Joined: May 2002
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?
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 704
Threads: 0
Joined: Dec 2002
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.
(I'm not sure that 90% of programming, period, wouldn't be gone.
)
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.
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.