Step Debug (newbie to BS2)
Archiver
Posts: 46,084
Is there a way to step through source code in debug mode. Also, is
the IF -Then statement a true branch or should the code return if it
goes to a subroutine. The manual seems to indicate that there is no
return unless the GOsub was used. Thanks
the IF -Then statement a true branch or should the code return if it
goes to a subroutine. The manual seems to indicate that there is no
return unless the GOsub was used. Thanks
Comments
to see what's happening.
The IF is just a branch. If you want to call a subroutine, you'll have to
put a gosub as the target of the IF and then jump back to where you want:
WRONG:
if x=10 then foo
gosub do_something_else
foo:
high 4
return
RIGHT:
if x=10 then call_foo
foo_ret:
gosub do_something_else
.
.
.
call_foo:
gosub foo
goto foo_ret
foo:
high 4
return
Of course, this assumes you are calling foo from somewhere else too, or else
you might just as well write:
if x=10 then foo
foo_ret:
gosub do_something_else
.
.
.
foo:
high 4
goto foo_ret
Another nice trick is to put a label (maybe RET) in front of any return
statement you happen to have in your program:
foo:
high 4
RET:
return
Then inside a subroutine you can write:
if x=100 then RET
to return conditionally from the subroutine.
Regards,
Al Williams
AWC
* Control 8 servos at once! http://www.al-williams.com/awce/pak8.htm
>
Original Message
> From: rheine@m... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=yVcG9Ue6-IkKIg2JIQKXhHPEVCh3xsLWNiqcWpTGQUAu70n6D_k3reHKpq7eVIpMLsTg0BezJXR2KEc]rheine@m...[/url
> Sent: Thursday, September 28, 2000 10:11 AM
> To: basicstamps@egroups.com
> Subject: [noparse][[/noparse]basicstamps] Step Debug (newbie to BS2)
>
>
> Is there a way to step through source code in debug mode. Also, is
> the IF -Then statement a true branch or should the code return if it
> goes to a subroutine. The manual seems to indicate that there is no
> return unless the GOsub was used. Thanks
>
>
>