No issues when using the script below outside of a function, but I want to tighten up the script.
Code: Select all
if !(i.vin=""||i.vin="null"||i.vin="false")
oSub["vin"] := i.vin
Code: Select all
Array_AddIf(Arr, Key, Value) {
if !(Value=""||Value="null"||Value="false")
Arr[Key] := Value
return Arr
}
Code: Select all
MergeTrailerTrader:
oTrailerTraderType1 := {}
j := 0
Loop, E:\Folder\Temp File Folder For Logs\TrailerTraderType1*.txt
{
FileRead, v, E:\folder\Temp File Folder For Logs\%A_LoopFileName%
v := json.load(v)
if !IsObject(v)
MsgBox, 262144, Error!, Object Creation Unsucessful
j += v.data.inventories.count()
ToolTip, % j
;~ continue
for e, i in v.data.inventories
{
oTrailerTraderType1[i.type_label] := {}
oSubTT := oTrailerTraderType1[i.type_label]
oSubTT[i.id] := {}
oSub := oSubTT[i.id]
oSub := Array_AddIf(oSub, "title", i.title)
oSub := Array_AddIf(oSub, "vin", i.vin)
oSub := Array_AddIf(oSub, "year", i.year)
oSub := Array_AddIf(oSub, "make", i.manufacturer)
oSub := Array_AddIf(oSub, "model", i.model)
oSub := Array_AddIf(oSub, "condition", i.condition)
oSub := Array_AddIf(oSub, "pull_type", i.pull_type)
oSub := Array_AddIf(oSub, "num_stalls", i.num_stalls)
oSub := Array_AddIf(oSub, "load_type", i.load_type)
oSub := Array_AddIf(oSub, "num_slideouts", i.num_slideouts)
oSub := Array_AddIf(oSub, "width_inches", i.width_inches)
oSub := Array_AddIf(oSub, "length_inches", i.length_inches)
oSub := Array_AddIf(oSub, "length", i.length)
oSub := Array_AddIf(oSub, "gvwr", i.gvwr)
oSub := Array_AddIf(oSub, "axle_capacity", i.axle_capacity)
oSub := Array_AddIf(oSub, "stock", i.stock)
if !(oSub.stock="")
{
RegExMatch(i.stock, "\d++", stock)
linkTag := "/all-inventory?stock=" stock
}
oSub := Array_AddIf(oSub, "website_price", i.website_price)
oSub := Array_AddIf(oSub, "description", i.description)
oSub := Array_AddIf(oSub, "dealer", i.location.name)
oSub := Array_AddIf(oSub, "phone", i.location.phone)
oSub := Array_AddIf(oSub, "city", i.location.city)
oSub := Array_AddIf(oSub, "state", i.location.region)
oSub := Array_AddIf(oSub, "link", i.location.website . linktag)
oSub := Array_AddIf(oSub, "stock", i.stock)
oSub := Array_AddIf(oSub, "stock", i.stock)
oImages := oSub["Images"]
for k, v in i.images
oImages.push(v)
}
MsgBox, 262144, oSub.count, % oSub.count()
for l, u in oSub
MsgBox, 262144, l/u, % l "`n`n" u
ToolTip, % oTrailerTraderType1.count()
}
;~ v := json.dump(oTrailerTraderType1)
;~ FileAppend, %v%, oTrailerTraderType1_20220527.txt
MsgBox, 262144, Merge Status:, DONE (%j%)
return
I'm sorry @Chunjee!! I just haven't got around to learning/adding/using your array/object class
(if I can't get this function ironed out I'm just going to drop down into the next line of v.data.inventories with another for each and use each and item for object.push(element))
**Edit: I noticed that I hadn't declared oSubTT[i.id] as an object oSubTT[i.id] := {} added
**Edit: I remembered why I didn't add that declaration as it would erase all the information on each itteration... oSubTT[i.id] := {} removed
**Edit: 10,000 Foot view... Added oSubTT[i.id] := {} back in AND Added oTrailerTraderType1[i.type_label] := {} in (to declare both as an object), and my current script seems to be working (no function). i'm going to switch it back to the function and test.