Amiga.org

Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: blakespot on October 11, 2013, 10:13:16 PM

Title: AmigaBASIC structural question...
Post by: blakespot on October 11, 2013, 10:13:16 PM
I've got a question for anyone that ever played around with AmigaBASIC. (Not ABasiC, but AmigaBASIC that came after.)

I have a program that is doing some GOSUBs to a subroutine. Inside that subroutine, I need to do a GOTO to a sub-section of the subroutine code, depending on a variable state. How is this done, with labels?

I try:

MySubroutine:
x=0:y=0
read x,y....blabla
...
...
...
...
if x > whatever then goto (that read line above)
RETURN

Whenever I change that read line to...

ReadLine: read x,y .....blablabla

and then...

...goto ReadLine

I get undefined routine error. Not wanting to use line numbers for this - AmigaBASIC wasn't setup for that, really.

Basically, how does on goto inside a subroutine, is the question?

Thanks!





bp
Title: Re: AmigaBASIC structural question...
Post by: itix on October 11, 2013, 10:21:42 PM
I have no experience with AmigaBASIC but you should use while statement instead.
Title: Re: AmigaBASIC structural question...
Post by: ElPolloDiabl on October 12, 2013, 03:20:49 AM
Do the goto on the next line:

IF x >
THEN GOTO subroutine
END IF
Title: Re: AmigaBASIC structural question...
Post by: Minuous on October 12, 2013, 05:23:10 AM
>Whenever I change that read line to...

>ReadLine: read x,y .....blablabla

IIRC labels need to be on their own separate line.
Title: Re: AmigaBASIC structural question...
Post by: Thorham on October 12, 2013, 07:00:25 AM
Quote from: ElPolloDiabl;749870
Do the goto on the next line:

IF x >
THEN GOTO subroutine
END IF

Learn to do it right, and use while instead of goto :p