Difference between revisions of "MC-Basic:PUBLIC SUB ... END SUB"

From SoftMC-Wiki
Jump to: navigation, search
Line 47: Line 47:
 
* [[MC-Basic:SUB ... END SUB|SUB ... END SUB]]
 
* [[MC-Basic:SUB ... END SUB|SUB ... END SUB]]
  
[[Category:Axystems:MC-Basic:Libraries|PUBLIC SUB ... END SUB]]
+
[[Category:MC-Basic:Libraries|PUBLIC SUB ... END SUB]]
  
 
}}
 
}}

Revision as of 09:16, 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

See Also