Control program flow
How are the methods goto, execute and transfer different?
SWML offers a lot of flexibility in how you control program flow with its control methods.
Of these, goto, execute, and transfer allow you to unconditionally control program flow.
goto
The goto method is designed to allow you to jump to particular labels within a section.
Use this method to simulate more complex loops like while and for loops.
You cannot jump to sections using goto.
Use execute described further below to jump sections.
execute
The execute method allows you to invoke a subsection as a function. You can pass parameters to the function
and receive a return value.
Output transcript:
Or in a more complex example:
transfer
Output transcript:
Notice how we aren’t going back to the calling section at all.