DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

ElementListOrABS does not support Count property

I'm using the OnDataStoreLoading event to grab some properties from loaded data, but I'm having a problem with the ElementListOrABS variable.  The variable passed to my function by the OnDataStoreLoading event is always an object, but sometimes it doesn't support the Count property. 

 

If I load data via the Navigator Panel, it works fint, ElementListorABS.Count works as expected.  But if I load data with a script using the Navigator.LoadData command, ElementListorABS IS and object, but I get this error:

 

78 2:47:27 PM Error:
Incorrect instruction or user command.
In <Load_Event_OnLoading.VBS> (line: 37, column: 5):
Object doesn't support this property or method: 'ElementListOrABS.Count'

 

How can I check if ElementListOrABS is an object AND supports the Count property?  

0 Kudos
Message 1 of 6
(4,247 Views)

Hi RussellSenior,

 

I tested this behavior, but could not reproduce it. I defined this user command:

 

Call AddUserCommandToEvent("Navigator.Events.OnDataStoreLoading","MyOnDataStoreLoading")

Sub MyOnDataStoreLoading (NaviLoadControl, ElementListOrABS, ImportAction)
  If IsObject(ElementListOrABS) Then
    Dim Element
    For Each Element in ElementListOrABS
      Call MsgBoxDisp("Element name: " & Element.Name)
    Next
  Else
    Call MsgBoxDisp("Event Parameter StorageABS" & VbCrLf & ElementListOrABS)
  End If
End Sub

and checked it interactively and with this script:

 

dim oLoadedData, oMySelection
set oMySelection = Navigator.Display.CurrDataStore.Browser.SelectedElements
dim oMyPropertyImportSet
set oMyPropertyImportSet = Nothing                                             ' Minimal configuration
set oLoadedData = Navigator.LoadData(oMySelection, "Load" ,oMyPropertyImportSet)     ' Use this line for DataStores without GUI

Both worked fine. I used DIAdem 2015

 

Greetings

Walter

0 Kudos
Message 2 of 6
(4,219 Views)

Element.Name always works for me too, it's the Element.Count property that sometimes doesn't.  If you load a single item from the MeasurmentQuantity level of a database, the Element.Count doesn't work.  If you load a Measurement level, it works fine. 

 

I modified your code a little to reflect how I am doing this, and it's at the bottom.  Again, I get an error if I load something from the MeasurmentQuantity level. My work around is this:

On Error Resume Next
MyCount = ElementListOrABS.Count
On error goto 0  

If MyCount is an empty string, I know I can't use count.  

 

 

 

 

 


Sub MyOnDataStoreLoading (NaviLoadControl, ElementListOrABS, ImportAction) If IsObject(ElementListOrABS) Then Dim i For i = 1 to ElementListOrABS.Count Call MsgBoxDisp("Element name: " & Element(i).Name) Next Else Call MsgBoxDisp("Event Parameter StorageABS" & VbCrLf & ElementListOrABS) End If End Sub

 

0 Kudos
Message 3 of 6
(4,205 Views)

I used your script code and tested it with DIAdem 2015 SP1. It worked fine for TestRun, Measurement and MeasurementQantity.

Which version do you use?

 

Greetings

Walter

0 Kudos
Message 4 of 6
(4,201 Views)

2014 sp1.  (14.0.0f5641)

 

Script engine: 5.5.0.5207

 

 

0 Kudos
Message 5 of 6
(4,197 Views)

I tested it with DIAdem 2015 SP1 and 2014 SP1 - both are working fine.

 

Here is my test script which works with the installed ASAM test dataset and my user command.

 

Dim oMyConditions
Dim oMyQueryForm
 
'--- Search without GUI
Dim oMyDataStore, oMyQuery, oMyResults
Set oMyDataStore = Navigator.ConnectDataStore("ASAM Pass Fail Analysis Example")
Set oMyQuery = oMyDataStore.CreateQuery()
oMyQuery.ReturnType = "MeaQuantity"
Set oMyConditions = oMyQuery.Conditions
 
'--- Fill the query
Call oMyConditions.Add("Measurement","Test_Operator","=","George")
Call oMyConditions.Add("Measurement","Test_Status","=","Fail")
Call oMyConditions.Add("MeaQuantity","maximum",">=",50)
oMyConditions.Logic = "C1 AND C2 AND C3"
 
'--- Search without GUI
Call oMyDataStore.Search(oMyQuery)
Set oMyResults = oMyDataStore.Results
 
Navigator.LoadData(oMyResults)
Call AddUserCommandToEvent("Navigator.Events.OnDataStoreLoading","MyOnDataStoreLoading")

Sub MyOnDataStoreLoading (NaviLoadControl, ElementListOrABS, ImportAction)
  If IsObject(ElementListOrABS) Then
    Dim iLoop
    For iLoop = 1 to ElementListOrABS.Count
      Call MsgBoxDisp("Element name: " & ElementListOrABS(iLoop).Name & " - " & str(iLoop) & " of " & ElementListOrABS.Count)
    Next
  Else
    Call MsgBoxDisp("Event Parameter StorageABS" & VbCrLf & ElementListOrABS)
  End If
End Sub

Please could you test it with these scripts?

 

Greetings

Walter

0 Kudos
Message 6 of 6
(4,171 Views)