Difference between revisions of "Sub"

From Wiki
Jump to: navigation, search
(Example 1)
 
Line 5: Line 5:
  
  
==== Example 1 ====
+
==== Example ====
 
<pre>
 
<pre>
 
mainloop:
 
mainloop:
Line 16: Line 16:
 
return
 
return
 
</pre>
 
</pre>
 
  
 
== Related Commands ==
 
== Related Commands ==

Latest revision as of 11:39, 3 August 2007

Synopsis

sub {sub name}

Description

The sub command starts a smaller macro within the macro. You transfer to the sub by using gosub elsewhere in the macro. Use return to go back to where the gosub was previously.

Note: You must not jump out of a sub! Use return to properly terminate a sub routine. To prevent a stack overflow, EUO only supports 1000 consecutive GoSubs without returning. Remember this when using recursion! When the GoSub stack is about to get 1001 levels, the very first level in the bottom of the stack is deleted to make room.


Example

mainloop:
 gosub speakgame hi
 wait 1s
goto mainloop

sub speakgame
   exevent macro 1 0 %1
return

Related Commands

Gosub Return

See also

Main Page Documentation