A SERVICE OF

logo

GENERIC ELEMENTS 06/2005 Danaher Motion
146 Rev E M-SS-005-03l
9.1.4. Functions
Generic elements can be defined “by reference” in MC-Basic functions and
subroutines. Axes or groups passed as arguments could be either “real” or
generic. For example, axis setup can be encapsulated in a subroutine. In this
example, the subroutine arguments are “real” axes:
Sub AxisSetUp(Ax As Generic Axis)
Ax.PFac = 0x8000
Ax.VFac = Ax.PFac/1000
Ax.AFac = Ax.VFac/1000
Ax.JFac = Ax.AFac/1000
Ax.VMax = 290
Ax.AMax = 1500
Ax.DMax = Ax.Amax
Ax.Acc = Ax.Amax
Ax.Dec = Ax.DMax
End Sub
Call AxisSetUp(A1)
Call AxisSetUp(A2)
Call AxisSetUp(A3)
Call AxisSetUp(A4)
An entire array of generic elements can be passed (by reference) to
functions and subroutines. Here, the argument is generic:
Sub AxesListSetUp(AxList[*] As Generic Axis)
Dim i as long
For i = 1 To Sys.NumberAxes
AxList[i].PFac = 0x8000
AxList[i].VFac = AxList[i].PFac/1000
AxList[i].AFac = AxList[i].VFac/1000
AxList[i].JFac = AxList[i].AFac/1000
Next
End Sub
Call AxesListSetUp(Gen_Axes_List)
The element type (i.e., axis or group) of an argument must match the
function or subroutine declaration. Otherwise, a translation error occurs.
Call AxisSetUp(G1) ‘ G1 is a group
-> Variable passed by reference has another type as in subroutine/function
declaration
Trying to define generic elements “by value” generates an error:
Sub AxisSetUp(ByVal Ax As Generic Axis)
End Sub
-> Cannot pass an axis or a group by value to subroutine/function
Joint (J) axes cannot serve as function or subroutine arguments.
Call AxisSetUp(G1.j1)
-> Syntax Error