06-14-2012 02:03 PM
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.
06-15-2012 01:05 AM
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:
01-29-2013 02:10 PM
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
01-30-2013 04:50 PM
Hi Jcheese,
Can you tell us more about what you would like this code to accomplish?
Thanks,
01-31-2013 09:09 AM
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.