Label loss in side IF statement

new BookmarkLockedFalling
veneff
New Member
*

veneff Avatar

Posts: 29

Post by veneff on Jan 16, 2009 10:24:39 GMT -5

Hello,

Why can't the label [Label1] be found?

Dummy = 2
GOTO [Label1]
Dummy = 3
IF (Dummy = 3) THEN
[Label1]
GOTO [ExitLabel]
ELSE
GOTO [ExitLabel]
END IF
[ExitLabel]

It returns error:
Runtime Error in program 'untitled': GOTO [Label1]
Branch label not found: [Label1]

It does not matter if [Label1] is moved to the ELSE portion of the IF.

Vance
Last Edit: Jan 16, 2009 10:25:46 GMT -5 by veneff
Psycho
Full Member
***

Psycho Avatar

Posts: 196

Post by Psycho on Jan 16, 2009 10:57:32 GMT -5

It's because you have it inside and IF/THEN loop, regardless of where in the loop it is. You'll need to change the structure of your program. If the program were to go to the [Label1] branch, it wouldn't know what to do when it encountered the "else" and "end if" statements because it wouldn't have gone through the opening "if".

John "Psycho" Siejkowski
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550

Post by Carl Gundel - admin on Jan 16, 2009 13:32:31 GMT -5

Psycho Avatar
It's because you have it inside and IF/THEN loop, regardless of where in the loop it is. You'll need to change the structure of your program. If the program were to go to the [Label1] branch, it wouldn't know what to do when it encountered the "else" and "end if" statements because it wouldn't have gone through the opening "if".

That's right. You can jump out of a code block but not into.

-Carl