I am running into some difficulty with the structure of the below piece of code, I have simplified the below as much as I can as an example of what I am attempting in a slightly more complex scenario.
Basically what I want to happen is for eg. in this example below is for the "send" subroutine to be called sequentially in the first part of the IF statement and then exit the loop.
However when the "return" happens from the 1st "send" subroutine the IF statement seems to pick up at the start of the IF loop and then re-enters into the 1st "send" subroutine, this occurs indefinitely.
I hope I have explained my issue clearly enough and the below highlights what I am trying to achieve.
Output from terminal shows it repeats the first send loop continuously.
Basically what I want to happen is for eg. in this example below is for the "send" subroutine to be called sequentially in the first part of the IF statement and then exit the loop.
However when the "return" happens from the 1st "send" subroutine the IF statement seems to pick up at the start of the IF loop and then re-enters into the 1st "send" subroutine, this occurs indefinitely.
I hope I have explained my issue clearly enough and the below highlights what I am trying to achieve.
Code:
Symbol lastlocation = w1
Symbol nextlocation = w2
Symbol last = w3
Symbol x = w4
Symbol y = w5
wait 10
lastlocation = 5
nextlocation = 2
goto main
main:
sertxd ( "+++START MAIN+++",cr,lf)
if lastlocation >= nextlocation then
last = 1
sertxd ( "IF loop last ",#last,cr,lf)
x = lastlocation + 1
y = 240
goto send
last = 2
sertxd ( "IF loop last ",#last,cr,lf)
x = 1
y = lastlocation
goto send
else
last = 3
sertxd ( "IF loop last ",#last,cr,lf)
x = 1
y = nextlocation
goto send
last = 4
sertxd ( "IF loop last ",#last,cr,lf)
x = nextlocation
y = 240
goto send
endif
sertxd ( "+++END MAIN+++",cr,lf)
goto main
send:
sertxd ( "lastlocation ",#lastlocation, 5,"nextlocation ",#nextlocation,5,"last ",#last,cr,lf)
return
Output from terminal shows it repeats the first send loop continuously.
Code:
+++START MAIN+++
IF loop last 1
lastlocation 5nextlocation 2last 1
+++START MAIN+++
IF loop last 1
lastlocation 5nextlocation 2last 1