We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to exit a subroutine half way through
#3
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()
Test2()

Sub Test1
  TextWindow.WriteLine("Used code 1")
  Goto subTest_Exit
  TextWindow.WriteLine("Unused code 1")
  subTest_Exit:
EndSub

Sub Test2
  TextWindow.WriteLine("Used code 2")
  If ("False") Then
    TextWindow.WriteLine("Unused code 2")
  EndIf
EndSub
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply


Messages In This Thread
RE: How to exit a subroutine half way through - by litdev - 11-11-2024, 12:59 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)