MC-Basic:PUBLIC SUB ... END SUB
Language: | English • 中文(简体) |
---|
Defines a library subroutine that can be called from any task. The structure is the same as SUB..END SUB, but it is used in a library file to allow calling from any task that imports the library. Subroutines may be recursive.
Syntax
Public SUB <name> ({ {ByVal} <p_1> as <type_1>}…{, {ByVal} <p_n> as <type_n>})
{ local variable declaration }
{ subroutine code }
END SUB
Availability
All versions
Type
Parmeters: Long, Double, String, Joint, Location, user defined structures, Generic Axis, Generic Group, Moving Frame (by reference only), Cam (by reference only), Comp (by reference only), Semaphore (by reference only), user defined Error and Note (by reference only).
Scope
Library only
Limitations
Arrays are passed only by reference.
Examples
Public Sub Sub1(lastLoop as Long) 'Pass parameters by reference
Dim Index as long
For Index = 1 to lastloop
move a1 1 abs = 0
Next Index
End Sub