DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

What am I mising in this code

Dim i, k, lst, params, j, temp, State, Dict

 

'Engine Operation State Value Change
if Data.Root.ChannelGroups(1).Channels.Exists("Engine Operating State") then
lst = globusedchn + 1
j = chnlength(1)
call chnalloc("Combustion_Control_Path_Owner",j)
for i = 1 to j
State = cht(i,"[1]/Engine Operating State")
IF Dict.Exists(State) THEN ---------------------------------------This gives the error below.
  chd(i,lst) = dict.Item("State")
  end if  'Dict
next
End if  'Parameter Name

 

 

Error

Object Required: "

 

I have tried changing(state) to ("state") and too "state" and continues to give me this error.

0 Kudos
Message 1 of 5
(4,939 Views)

I assume you are missing the dic object. So the error just refers that dict has to be an object if you want to call a method ".Exists" on it.

 

Option Explicit  'Forces the explicit declaration of all the variables in a script.

Dim i, k, lst, params, j, temp, State, Dict

Set Dict = CreateObject("Scripting.Dictionary")
Call Dict.Add("a", 1)  
Call Dict.Add("b", 2)
Call Dict.Add("c", 3)

'Engine Operation State Value Change
if Data.Root.ChannelGroups(1).Channels.Exists("Engine Operating State") then
lst = globusedchn + 1
j = chnlength(1)
call chnalloc("Combustion_Control_Path_Owner",j)
for i = 1 to j
State = cht(i,"[1]/Engine Operating State")
IF Dict.Exists(State) THEN
  chd(i,lst) = dict.Item(State)
  end if  'Dict
next
End if  'Parameter Name

 I changed two things:

  • Inserted dictonary
  • Call dict.Item("State") to dict.Item(State) to do a lookup of the state.
0 Kudos
Message 2 of 5
(4,935 Views)

I am working on this and the script says that it completes but does not add a channel to my list? 

 

 

Dim J, i, State, dict
Set Dict = CreateObject("Scripting.Dictionary")

'-----------------------------------------------------------
'Add Dealer_Code_Name_Description's------------
'-----------------------------------------------------------
Dict.Add "00005","00005 - MURRAY'S FORD, INC. (DUBOIS)"
Dict.Add "10019","10019 - MARIETTA MACK"
Dict.Add "10026","10026 - FYDA FREIGHTLINER PITTSBURGH INC. (BARKEYVILLE)"
Dict.Add "10030","10030 - MIDWAY INC. - MANSFIELD DIVISION"

 

for i = 1 to j
'Engine Operating State
if Data.Root.ChannelGroups(1).Channels.Exists("Dealer_Code") then
State = cht(i,"[1]Dealer_Code")
IF Dict.Exists(State) THEN
chd(i,"[1]/DEALER_CODE_1") = dict.Item(State)
else
chd(i,"[1]/DEALER_CODE_1") = 0
end if 'Dict
end if 'Parameter Name

next

Download All
0 Kudos
Message 3 of 5
(4,779 Views)

Hi Jcheese,

 

Can you tell us more about what you would like this code to accomplish?  

 

Thanks,

Daniel Dorroh
National Instruments
0 Kudos
Message 4 of 5
(4,757 Views)

I am trying to do a sample count that will tell me how many times the "Dealer_Code" was found and produce a new column with that value.  I would also like to use that in a plot over time frame - I will have to take the "Requested Date" and break that down into a month time column.  Hope that helps.

0 Kudos
Message 5 of 5
(4,746 Views)