dbh6
Lifetime Supporting Member
Hello All,
HMI application I'm using is GE's HMI/SCada Cimplicity. Im writing a basic program in the script to do as follows.
When the operator enters a value, the code will return a locations as to what screen to go to and what the index number is in plain text. In cimplicity you can specify what programming language to use from Basic, Visual Basic or C#. Since this is an existing project that i'm making additions to i did it in basic which is fairly similar to Visual basic because all the existing code is in basic.
Ok so in my case their exists a String Variable that has an array size of 17 (0-16), lets call this string F1_PRODUCT_CODES. Each array index starting from array index 1 (Yes im not starting at array index 0) has a preset value so for example F1_PRODUCT_CODES[1] = 80344F
So what basically happens is when an operator enters a value and presses a search button, my code just compares to find a match, if it does it outputs to the HMI the locations of whatever string you specify in this case i used F1 and an Index number, sounds simple. So below i highlighted what i did without a For Next Loop for two iterations as an example, and then i highlighted one with a For Next Loop.
In conclusion, without using the For next loop, it worked, but that would be tedious and overwhelming to do because i have to do the same to a whole bunch of stuff as well. So if you have the time of day, let me know if you can see the bug for the program using the For Next loop.
I keep getting a error in configurations for point for what i put in bold below, maybe my syntax is wrong
Var1 = PointGet("Letter"&"_PRODUCT_CODES"&"[Index]")
Without for next loop:
Sub Main()
'Declare variables
Dim Var1 As String * 20
Dim Operator_Entry As String * 20
Dim Screen_Location As String * 80
Dim Index_Number As Integer
'Get the input that was entered by the operator
Operator_Entry = PointGet("PRODUCT_CODE_ENTRY")
'Compare the data coming from the database, if equal with the inputed data then display Letter and Index#
Var1 = PointGet("F1_PRODUCT_CODES[1]")
If Var1 = Operator_Entry Then
Screen_Location = "F1 Manifold"
Index_Number = 1
'Sets the current Values to the HMI
PointSet "SCREEN_LOCATION_HMI",Screen_Location
PointSet "INDEX_NUMBER_HMI",Index_Number
GoTo End_Check
End If
'Compare the data coming from the database, if equal with the inputed data then display Letter and Index#
Var1 = PointGet("F1_PRODUCT_CODES[2]")
If Var1 = Operator_Entry Then
Screen_Location = "F1 Manifold"
Index_Number = 2
'Sets the current Value the HMI
PointSet "SCREEN_LOCATION_HMI",Screen_Location
PointSet "INDEX_NUMBER_HMI",Index_Number
GoTo End_Check
End If
End_Check:
PointSet "SEARCH_BUTTON",0
End Sub
With for next loop:
Sub Main()
'Declare variables
Dim Var1 As String * 20
Dim Operator_Entry As String * 20
Dim Screen_Location As String * 80
Dim Index As Integer
Dim Index_Number As Integer
Dim Letter As String * 20
Dim Max_Index_Number As Integer
'Initialize values and Get Values from HMI
Max_Index_Number = 16
Operator_Entry = PointGet("PRODUCT_CODE_ENTRY")
'When Letter is equal to F1
Letter = "F1"
For Index_number = 1 To Max_Index_Number
GoSub Check_Test
Next Index_number
Check_Test:
Var1 = PointGet("Letter"&"_PRODUCT_CODES"&"[Index]")
If Var1 = Operator_Entry Then
Screen_Location = "Letter"&" "&"Manifold"
Index_Number = Index
PointSet "SCREEN_LOCATION_HMI",Screen_Location
PointSet "INDEX_NUMBER_HMI",Index_Number
GoTo Found_Match
End If
Found_Match:
PointSet "SEARCH_BUTTON",0
End Sub
HMI application I'm using is GE's HMI/SCada Cimplicity. Im writing a basic program in the script to do as follows.
When the operator enters a value, the code will return a locations as to what screen to go to and what the index number is in plain text. In cimplicity you can specify what programming language to use from Basic, Visual Basic or C#. Since this is an existing project that i'm making additions to i did it in basic which is fairly similar to Visual basic because all the existing code is in basic.
Ok so in my case their exists a String Variable that has an array size of 17 (0-16), lets call this string F1_PRODUCT_CODES. Each array index starting from array index 1 (Yes im not starting at array index 0) has a preset value so for example F1_PRODUCT_CODES[1] = 80344F
So what basically happens is when an operator enters a value and presses a search button, my code just compares to find a match, if it does it outputs to the HMI the locations of whatever string you specify in this case i used F1 and an Index number, sounds simple. So below i highlighted what i did without a For Next Loop for two iterations as an example, and then i highlighted one with a For Next Loop.
In conclusion, without using the For next loop, it worked, but that would be tedious and overwhelming to do because i have to do the same to a whole bunch of stuff as well. So if you have the time of day, let me know if you can see the bug for the program using the For Next loop.
I keep getting a error in configurations for point for what i put in bold below, maybe my syntax is wrong
Var1 = PointGet("Letter"&"_PRODUCT_CODES"&"[Index]")
Without for next loop:
Sub Main()
'Declare variables
Dim Var1 As String * 20
Dim Operator_Entry As String * 20
Dim Screen_Location As String * 80
Dim Index_Number As Integer
'Get the input that was entered by the operator
Operator_Entry = PointGet("PRODUCT_CODE_ENTRY")
'Compare the data coming from the database, if equal with the inputed data then display Letter and Index#
Var1 = PointGet("F1_PRODUCT_CODES[1]")
If Var1 = Operator_Entry Then
Screen_Location = "F1 Manifold"
Index_Number = 1
'Sets the current Values to the HMI
PointSet "SCREEN_LOCATION_HMI",Screen_Location
PointSet "INDEX_NUMBER_HMI",Index_Number
GoTo End_Check
End If
'Compare the data coming from the database, if equal with the inputed data then display Letter and Index#
Var1 = PointGet("F1_PRODUCT_CODES[2]")
If Var1 = Operator_Entry Then
Screen_Location = "F1 Manifold"
Index_Number = 2
'Sets the current Value the HMI
PointSet "SCREEN_LOCATION_HMI",Screen_Location
PointSet "INDEX_NUMBER_HMI",Index_Number
GoTo End_Check
End If
End_Check:
PointSet "SEARCH_BUTTON",0
End Sub
With for next loop:
Sub Main()
'Declare variables
Dim Var1 As String * 20
Dim Operator_Entry As String * 20
Dim Screen_Location As String * 80
Dim Index As Integer
Dim Index_Number As Integer
Dim Letter As String * 20
Dim Max_Index_Number As Integer
'Initialize values and Get Values from HMI
Max_Index_Number = 16
Operator_Entry = PointGet("PRODUCT_CODE_ENTRY")
'When Letter is equal to F1
Letter = "F1"
For Index_number = 1 To Max_Index_Number
GoSub Check_Test
Next Index_number
Check_Test:
Var1 = PointGet("Letter"&"_PRODUCT_CODES"&"[Index]")
If Var1 = Operator_Entry Then
Screen_Location = "Letter"&" "&"Manifold"
Index_Number = Index
PointSet "SCREEN_LOCATION_HMI",Screen_Location
PointSet "INDEX_NUMBER_HMI",Index_Number
GoTo Found_Match
End If
Found_Match:
PointSet "SEARCH_BUTTON",0
End Sub