Hello again,
It looks like I will need to jump out of a While loop. Is there any other way to do it apart from connection points? Also, would this then mean the stack would increase in size as the pointers wont get cleared down?
Thanks
Matt
Jumping out of a Loop
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Jumping out of a Loop
Hi Matt,
We are investigating adding Break and Continue icons for FC8.
For now you can either use connection points or you can add a statement to the while loop decision.
For example to only loop when varA is not 0 and varB is less than 10 you would do this.
We are investigating adding Break and Continue icons for FC8.
For now you can either use connection points or you can add a statement to the while loop decision.
For example to only loop when varA is not 0 and varB is less than 10 you would do this.
Code: Select all
(varA != 0) && (varB < 10)
Goto's only work inside the macro your currently in and a while loop does not use stack, therefore jumping around using connection points won't add garbage or clutter to the stack but is generally considered bad practise as it can make it harder to follow the program execution when debugging.Also, would mean the stack would increase in size as the pointers wont get cleared down?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Jumping out of a Loop
Hi Ben,
At the moment the main routine is the one which will require me jumping out of a loop and not a macro.
Thanks
Matt
Sorry to be a pain!! just to help me understand (my knowledge is from the Z80 days) is it not the case the starting point address of loops (also subroutines and interrupts) are stored on the Stack and then removed when an equivalent of a Return command (old school phrase) is encountered?Also, would mean the stack would increase in size as the pointers wont get cleared down?
Goto's only work inside the macro your currently in and a while loop does not use stack, therefore jumping around using connection points won't add garbage or clutter to the stack but is generally considered bad practise as it can make it harder to follow the program execution when debugging.
At the moment the main routine is the one which will require me jumping out of a loop and not a macro.
Thanks
Matt
Last edited by Docara on Mon Aug 14, 2017 3:31 pm, edited 1 time in total.
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Jumping out of a Loop
Subroutines and interrupts get "called" and cause a push of pc to the stack, which pops on a return (as you stated)
This does not apply to jumps, loops, go to etc
This does not apply to jumps, loops, go to etc