KB-67793: Using an array in a script with Function instruction in Elipse E3.

Question:

How can I create a Function instruction in an E3 script with an array?

Solution:

To do so, use a script similar to the one in the example below:

Sub CommandButton1_Click()
‘ Data operations sent at the Function
Dim value(3)

‘ Return of values used in the operation function
return = Operation (value)
MsgBox value(0)
MsgBox value(1)
MsgBox value(2)
MsgBox value(3)
End Sub

‘Function Declaration
Function Operation(value)
value(0) = Screen.Item(“sp1”).Value + Screen.Item(“sp2”).Value
value(1) = Screen.Item(“sp1”).Value – Screen.Item(“sp2”).Value
value(2) = Screen.Item(“sp1”).Value * Screen.Item(“sp2”).Value
value(3) = Screen.Item(“sp1”).Value / Screen.Item(“sp2”).Value
Operation = value
End Function

‘Used for eliminating last Sub’s function

Sub Empty()
End Sub

NOTE: The objects “sp1” and “sp2” are setpoints used for changing the Function‘s values, and can be replaced by fixed values.
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *