Difference between revisions of "Gosub"

From Wiki
Jump to: navigation, search
(Example)
(Example 1)
Line 13: Line 13:
 
   display ok %1 && %2 even %0 , gether < una
 
   display ok %1 && %2 even %0 , gether < una
 
return
 
return
 +
  
 
; syntax =  
 
; syntax =  
 
;  gosub {subName} [parameters...]
 
;  gosub {subName} [parameters...]
 +
 
gosub example_goSub These are the parameters
 
gosub example_goSub These are the parameters
  
==== Example 2 ====
 
  
 
sub example_goSub
 
sub example_goSub

Revision as of 15:18, 27 August 2005

Synopsis

gosub {sub name} {param1, param2, ...}

Description

The gosub command transfers the execution to a sub with the name given by the parameter.

Parameters can be added after the sub name. They will be transfered in the variables %1, %2, and so on. The variable %0 holds the number of parameters passed.

Example 1

gosub s7IsGreaterThan CEO RK
; %1 = CEO
; %2 = RK
; %0 = 2
sub s7IsGreaterThan CEO RK
   display ok %1 && %2 even %0 , gether < una
return


; syntax = 
;   gosub {subName} [parameters...]

gosub example_goSub These are the parameters


sub example_goSub
; %0 = 4
; %1 = These
; %2 = are
; %3 = the
; %4 = parameters
set %message
for %_cnt 1 %0
{
   set %message %message , % . %_cnt , #spc
}
display ok %message
halt


See also

Main Page Documentation