AKD BASIC User Guide | 6 AKD BASIC Parameters, Operators, Statements
6.1.20 Sub...End Sub
General Information
Type Statement
Description
The Sub statement declares a sub procedure and defines the sub procedures
format.
Units N/A
Range N/A
Default
Value
N/A
Data Type N/A
Start Ver-
sion
TBD
Description
The Sub statement declares a sub procedure and defines the sub procedures format. A sub pro-
cedure is invoked with the Call statement. A sub-procedure can accept arguments like a func-
tion, but does not return any value. If the sub-procedure does not take any arguments then it is
illegal to provide an empty argument-list "( )" either when defining the sub-procedure or when
calling it.
Example
This example defines a sub-procedure that takes one integer argument.
Main
dim x as integer
for x = 1 to 10
call MySub(x)
pause(1)
next
End Main
Sub MySub(a as integer)
print a;"---> ";
if a <= 5 then
print a * 0.5
else
print a * 2.0
end if
End Sub
Related Topics
Call | Function | Exit
Kollmorgenâ„¢ | March 30, 2012 118