Exit the current script or subroutine. - Forum

Forum Navigation
You need to log in to create posts and topics.

Exit the current script or subroutine.

Hi there.

How can I stop the subroutines?

Am I using "Return"? And how?

@tilesoft

How can I stop the subroutines?
Am I using "Return"?

Yes

And how?

Try this

a) Setup 2 Input Boxes with variables [Amount] and [Discount]

b) Setup a Button with this code ...

SetVar "[Trace]" "Before calling amountSubroutine"
SetVar "[Trace]" "[Trace]<br/>Discount=[Discount], Amount=[Amount]"
amountSubroutine
SetVar "[Trace]" "[Trace]<br/>Returned from amountSubroutine"
SetVar "[Trace]" "[Trace]<br/>Amount=[Amount]"
AlertBox "Trace" "[Trace]" ""

c) create a subroutine (named amountSubroutine)with this code ...

If [Discount] = 5
   Math "[Amount]-5" 0 "[Amount]"
   ... parameter for Return command is immaterial in this example
   Return ""
EndIf
Math "[Amount]-2" 0 "[Amount]"

When you setup [Discount] as 5, it subtracts 5 from [Amount]; otherwise, it subtracts 2

luishp and tilesoft have reacted to this post.
luishptilesoft

Thank you!

And Can you stop the subroutine with a button? (Otherwise when user click on the button, stop a subroutine).

@tilesoft

And Can you stop the subroutine with a button? (Otherwise when user click on the button, stop a subroutine).

Not immediately nor automatically. At least not that I know of any method.

But if the subroutine is servicing some kind of (long running) loop/endloop type of script, you can have it check the value of some variable (e.g. [quitAccountLoop]) at each iteration ... the other Button would then set the value of this variable (e.g. "yes") when clicked.