SUB

Top  Previous  Next

Action

Defines a Sub procedure.

 

 

Syntax

SUB Name[(var1)]

 

 

Remarks

name

Name of the sub procedure, can be any non reserved word.

var1

The name of the parameter.

 

You must end each subroutine with the END SUB statement.

 

 

You must Declare Sub procedures before the SUB statement.

The parameter names and types must be the same in both the declaration and the Sub procedure.

 

Parameters are global to the application.

That is the used parameters must be dimensioned with the DIM statement.

Therefore, the variables can be used by the program and sub procedures.

The following examples will illustrate this :

 

Dim a as byte, b1 as byte, c as byte        'dim used variables

Declare Sub Test(a as byte)                        'declare subroutine

a = 1 : b1 = 2: c = 3                        'assign variables

 

Print a ; b1 ; c                                'print them

 

Call Test(b1)                                        'call subroutine

Print a ;b1 ; c                                'print variables again

End

 

Sub Test(a as byte)                                'begin procedure/subroutine

print a ; b1 ; c                                'print variables

End Sub

 

 

See also

CALL, DECLARE

 

 

Example

NONE