EXIT SUB
EXIT SUB provides an early exit from a defined subroutine.
Only one space is allowed between the two words.
See also:
END FUNCTION
END SUB
EXIT FUNCTION
FUNCTION
LOCAL
SUB
Electronic Products for Creative Minds
EXIT SUB provides an early exit from a defined subroutine.
Only one space is allowed between the two words.
See also:
END FUNCTION
END SUB
EXIT FUNCTION
FUNCTION
LOCAL
SUB
Defines a callable function. This is the same as adding a new function to MMBasic while it is running your program.
‘xxx’ is the function name and it must meet the specifications for naming a variable. ‘arg1’, ‘arg2’, etc are the arguments or parameters to the function.
To set the return value of the function you assign the value to the function’s name.
1 2 3 |
FUNCTION SQUARE(a) SQUARE = a * a END FUNCTION |
Every definition must have one END FUNCTION statement. When this is reached the function will return its value to the expression from which it was called. The command EXIT FUNCTION can be used for an early exit.
You use the function by using its name and arguments in a program just as you would a normal MMBasic function.
1 |
PRINT SQUARE(56.8) |
When the function is called each argument in the caller is matched to the argument in the function definition. These arguments are available only inside the function.
Functions can be called with a variable number of arguments. Any omitted arguments in the function’s list will be set to zero or a null string.
Arguments in the caller’s list that are a variable (ie, not an expression or constant) will be passed by reference to the function. This means that any changes to the corresponding argument in the function will also be copied to the caller’s variable.
You must not jump into or out of a function using commands like GOTO, GOSUB, interrupts, etc. Doing so will have undefined side effects.
See also:
END FUNCTION
END SUB
EXIT FUNCTION
EXIT SUB
LOCAL
SUB
Defines a list of variable names as local to the subroutine or function.
‘variable’ can be an array and the array will be dimensioned just as if the DIM command had been used.
A local variable will only be visible within the procedure and will be deleted (and the memory reclaimed) when the procedure returns.
If the local variable has the same name as a global variable (used before any subroutines or functions were called) the global variable will be hidden by the local variable while the procedure is executed.
See also:
END FUNCTION
END SUB
EXIT FUNCTION
EXIT SUB
FUNCTION
SUB