Cimplicity CimEvent object


Thread Starter


I'm trying to use the CimEvent object in script of a button object, for instance :
Dim project As CimProject
Set project = CreateObject("CimProject")
project.OpenLocalProject "C:\Program Files\CIMPLICITY\HMI\projects\cimpdemo\cimpdemo.gef"
project.dynamicMode = True

Dim eventList As CimEventList
Set eventList = project.Events
' Retrieve event from event list

Dim e1 As CimEvent
Set e1=eventList.Item("TEST_EVENT")
If Not e1.Enabled Then
e1.Enable = True
e1.Enabled= False
End If
' Modify event in the event list
eventList.Modify e1

But the BCE compiler complains that Enabled is not a property of e1, why?
In your example you specified the 'Enable' property in different ways:



e1.Enabled <= see, Enable'd' d, d-d-d-d

This is a common mistake with VB-like programming languages/scripts. Another thing to look for is making slight typos in variable names while coding. Be sure to include OPTION EXPLICIT at the top of each script/module, else the CimBasic engine will, by default, declare a new Integer type variable with the misspelled name, initialize it to zero, and continue execution. (Very difficult bug to find.)

[email protected]
Great suggestion about using OPTION EXPLICIT. Another thing that really helps is to always type your property names in all lower case. If you have typed it correctly, VB or VBA will change the name to the correct case, if it doesn't change the case, you have a typo and it isn't going to work. If you declare variables it works the same way, declare your variable with mixed case, Dim intTestInt as Integer, and when you use the variable type in "inttestint" and it will change to "intTestInt", indicating that you have entered it correctly.

Bill Irish