Appendix B
06/2005
Danaher Motion
186 Rev
E
M-SS-005-03
Points in Functions
Point variables can be passed to functions and subroutines both by reference and by value.
An entire array of points can also be passed (by reference) to a function or subroutine. On
the other hand, point properties and vectors can only be passed by value. Points can also
serve as return values of functions. However, the point type and size (or robot type) of an
argument or a return value must match function declaration.
P
ASSING
B
Y
V
ALUE
A
ND
R
EFERENCE
A point can be passed by value and by reference like any other data type. For example:
Program
Dim p1 as joint of XYZR
Call Sub1(P1)
?p1
End program
Sub Sub1(X as joint of XYZR)
X = {1,2,3,4}
End Sub
This program assigns P1 to {1, 2, 3, 4} and prints {1, 2, 3, 4} as output. When a point is
passed by reference or value, you can only pass a point of the same robot type to
X
.
Otherwise, you receive a translation error.
Example1:
Program
Dim p1 as location of XYZR
Call Sub1(P1
Æ
TRANSLATION ERROR !!!
?p1
End program
Sub Sub1(X as location of XYZ)
X = #{1,2,3,4}
End Sub
Example2:
Program
Dim p1 as joint of XYZR
Call Sub1(P1)
Æ
TRANSLATION ERROR !!!
?p1
End program
Sub Sub1 (ByVal X as joint of XYZ)
X = {1,2,3,4}
End Sub
R
ETURNING
P
OINT
F
ROM
F
UNCTION
A function can return a point variable like any other data type. For example:
Dim A as location of XYZR
Program
Move G1 MyFunc(1) vcruise=299
Æ
this will be OK if G1 is of XYZR robot type.
End Program
Function MyFunc(i1 as long) as location of XYZR
MyFunc = #{1,2,3,4}
End Function