Difference between revisions of "MC-Basic:PUBLIC SUB ... END SUB"
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{Languages|MC-Basic:PUBLIC_SUB_..._END_SUB}} | ||
+ | |||
{{MC-Basic | {{MC-Basic | ||
|SHORT FORM= | |SHORT FORM= | ||
Line 47: | Line 49: | ||
* [[MC-Basic:SUB ... END SUB|SUB ... END SUB]] | * [[MC-Basic:SUB ... END SUB|SUB ... END SUB]] | ||
− | [[Category | + | [[Category:MC-Basic:Libraries|PUBLIC SUB ... END SUB]] |
}} | }} |
Latest revision as of 01:54, 11 April 2017
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