Difference between revisions of "MC-Basic:PUBLIC SUB ... END SUB"
m (Miborich moved page Axystems:MC-Basic:PUBLIC SUB ... END SUB to MC-Basic:PUBLIC SUB ... END SUB: Global renaming of Axystems: namespace into (Main):) |
|||
Line 45: | Line 45: | ||
|SEE ALSO= | |SEE ALSO= | ||
* [[MC-Basic:PROGRAM ... END PROGRAM|PROGRAM ... END PROGRAM]] | * [[MC-Basic:PROGRAM ... END PROGRAM|PROGRAM ... END PROGRAM]] | ||
− | * [[ | + | * [[MC-Basic:SUB ... END SUB|SUB ... END SUB]] |
[[Category:Axystems:MC-Basic:Libraries|PUBLIC SUB ... END SUB]] | [[Category:Axystems:MC-Basic:Libraries|PUBLIC SUB ... END SUB]] | ||
}} | }} |
Revision as of 08:41, 22 May 2014
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