03-27-2017, 10:13 AM
03-27-2017, 11:23 AM
If you want to simulate the GOTO statement you can use a loop like this one:
The variable Line is simulating the BASIC line number, each bloc is executed depending on the value of Line and at the end of each block you have to set Line to the value of the next bloc to be executed, this way you can “jump” to the line number you want. You exit the sequence by setting Line to 0.
This should work but it is pretty cumbersome. It may be better to change your code to avoid the need of GOTO.
See here for the original idea.
Code:
EXPORT Test()
BEGIN
LOCAL Line;
Line:=1;
WHILE Line<>0 DO
CASE
IF Line==1 THEN <Block1>;Line:=2; END;
IF Line==2 THEN <Block2>;Line:=3; END;
IF Line==3 THEN <Block3>;Line:=4; END;
IF Line==4 THEN <Block4>;Line:=5; END;
IF Line==5 THEN <Block5>;Line:=6; END;
IF Line==6 THEN <Block6>;Line:=0; END;
DEFAULT Print("Error, Line: "+Line);
END;
END;
END;
The variable Line is simulating the BASIC line number, each bloc is executed depending on the value of Line and at the end of each block you have to set Line to the value of the next bloc to be executed, this way you can “jump” to the line number you want. You exit the sequence by setting Line to 0.
This should work but it is pretty cumbersome. It may be better to change your code to avoid the need of GOTO.
See here for the original idea.
03-27-2017, 12:22 PM
Since you have 6 single program blocks, would configuring them as subroutines work for you? You can then "goto" them by using their program name.
Here's a little example:
Here's a little example:
Code:
// Declare Subroutines Here
clrscrn(); // Clears screen and redraws softmenu
// prog1(); // Your subroutines here ...
// prog2();
// prog3();
// prog4();
// prog5();
// prog6();
EXPORT concept()
BEGIN
clrscrn;
RECT_P(G0,0,0,320,220,rgb(0,255,0));
WAIT(2);
// Do some things.
// .
// prog3; // subroutine might be used here
// .
// --------------
clrscrn;
RECT_P(G0,0,0,320,220,rgb(255,0,0));
WAIT(2);
// Do some more things.
// .
// prog5; // subroutine might be used here, etc.
// .
// --------------
END;
// ==== End of Main Program ====
// ---- Subroutine Programs ----
clrscrn()
BEGIN
RECT(); // Clear Screen
DRAWMENU("Prog1","Prog2","Prog3","Prog4","Prog5","Prog6"); // Menu labels
RETURN;
END;
// ==== End of clrscrn() Subroutine ====
03-29-2017, 07:13 AM
@ Didier, Thanks for your suggestions, which are great!