SUB, FUNC (PSUB)

Defines a function (subroutine) for using with GOSUB or CALL.

Syntax

sub <functionname>
func <functionname>

Parameters

functionname
  • Name of function. May consists of letters, digits, and underscore symbol.

Remarks

Valid function names
sub abc
sub Abc
sub ABC
sub Func1
sub Func100
sub Func_100
Invalid function names
sub 10ABC
sub 7cycles

Example

sleeps 500   ; Set Sleeps = 500 ms
 
gosub FUNCTION5   ; This line will be skipped in that FUNCTION5 is not defined
gosub FUNCTION1   ; Call FUNCTION1
 
CYCLE:       ; Define Label "CYCLE"
 
gosub FUNCTION2 3 ; Call FUNCTION2 for 3 times
call FUNCTION3    ; Call FUNCTION3
 
goto CYCLE    ; Infinite cycle
 
; =================================
sub FUNCTION1 ; Define FUNCTION1
  10
ret           ; End of function
 
sub FUNCTION2 ; Define FUNCTION2
  rol
ret           ; End of function
 
sub FUNCTION3 ; Define FUNCTION3
  ror 2
ret           ; End of function
exgosub.mr_g.gif
exgosub.mr_r.gifexgosub.mr_b.gifexgosub.mr_r.gif