Difference between revisions of "Sub"

From Wiki
Jump to: navigation, search
Line 1: Line 1:
 
{{command header|Flow Control}}
 
{{command header|Flow Control}}
{{body|sub {sub name} |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.  
+
{{body | sub {sub name} |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.}}
 
{{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.}}

Revision as of 11:38, 3 August 2007

{{body | sub {sub name} |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 1

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