How to exit a subroutine half way through - Printable Version +- Small Basic Forum (https://litdev.uk/mybb) +-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1) +--- Forum: Standard Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=2) +--- Thread: How to exit a subroutine half way through (/showthread.php?tid=153) |
How to exit a subroutine half way through - Yumda - 11-11-2024 Hi there: Just not sure if this is possible with small basic. Been trying to exit a subroutine half way through but so far does not have much success, any ideas ? All help is much appreciated. Regards RE: How to exit a subroutine half way through - AbsoluteBeginner - 11-11-2024 (translated by Google translator) Hello, Yumda. At the very end of the subroutine, I insert some necessary line of code or an empty operation, like this: "x = x". Before this line I insert a transition label, for example: "subName_Exit:". Now I can jump to the end of the subroutine from anywhere in the code to exit it. ' --- Sub Test ... ' any code Goto subTest_Exit ... ' any code subTest_Exit: x = x EndSub ' ---- RE: How to exit a subroutine half way through - litdev - 11-11-2024 Either Goto as AB showed (don't need the x=x though) or encase unwanted code in If ("False"). Note you must keep the GoTo jump within the same subroutine. Code: Test1() |