If.. Gosub
Archiver
Posts: 46,084
Hello Michel,
Unfortunately, the IF/THEN statement in PBASIC only supports an implied GOTO
label:.
You can implement the logic you want in this manner:
IF variable <> 1 THEN Not1:
GOSUB Label1:
Not1:
...
END ' or GOTO an earlier part of the program; don't just "crash" into your
subroutines!
Label1:
...
RETURN
Or, like this:
IF variable = 1 THEN Yes1:
GOTO Not1:
Yes1:
GOSUB Label1:
Not1:
...
END ' or GOTO an earlier part of the program; don't just "crash" into your
subroutines!
Label1:
...
RETURN
Hope this helps..
Steve
De Meester, Michel [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Wrpa6lHvbqNPjlnguBGd4EO5oVM2g_XeoN0-4U7naW_ai9nh5e9AccRvIRFJTi6HP8xdv2Nicf4ri-1MiF0iV4lD0LKQQfl5]Michel.De.Meester@u...[/url wrote:
Is there a possibility to jump to a subroutine after an IF Then statement,
something like:
If variable = 1 then gosub label
label:
....
return
<snip>
Unfortunately, the IF/THEN statement in PBASIC only supports an implied GOTO
label:.
You can implement the logic you want in this manner:
IF variable <> 1 THEN Not1:
GOSUB Label1:
Not1:
...
END ' or GOTO an earlier part of the program; don't just "crash" into your
subroutines!
Label1:
...
RETURN
Or, like this:
IF variable = 1 THEN Yes1:
GOTO Not1:
Yes1:
GOSUB Label1:
Not1:
...
END ' or GOTO an earlier part of the program; don't just "crash" into your
subroutines!
Label1:
...
RETURN
Hope this helps..
Steve
De Meester, Michel [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=Wrpa6lHvbqNPjlnguBGd4EO5oVM2g_XeoN0-4U7naW_ai9nh5e9AccRvIRFJTi6HP8xdv2Nicf4ri-1MiF0iV4lD0LKQQfl5]Michel.De.Meester@u...[/url wrote:
Is there a possibility to jump to a subroutine after an IF Then statement,
something like:
If variable = 1 then gosub label
label:
....
return
<snip>