I have trouble adding value to an array of objects (I hope I am naming this properly).
I was able to add property "single" in the following matter:
Code: Select all
People := Array() ; or {}
People.Rick := {Year: "1986", Relation: "Friend"}
People.Rick.Status := "Single"
People.Bob := {Year: "1988", Relation: "Cousin"}
People.Jack := {Year: "1990", Relation: "Brother"}
MsgBox % People.Rick.Year . "`r" . People.Rick.Status
Code: Select all
User.property1=value
User.property2=value3xx
Another.property1=valuex
Code: Select all
oArray := Array()
Loop Parse, vText, % "`n", % "`r"
{
oTemp := StrSplit(A_LoopField, "=")
val:=oTemp.2
vTemp :=StrSplit(oTemp.1, ".")
key:=vTemp.1
prop:=vTemp.2
;oArray[key[A_Index]] := key[A_Index]
/*
oArray[key] := key
oArray[key].key := { (prop) : val }
*/
;oArray[key].Insert({(prop) : val })
;oArray.key.Push(Object(prop, val ))
oArray[%key%][%prop%] := val
;oArray.Insert( key, {(prop) :val})
;oArray .= { (key) : (key) }
}
I have read many posts and still not sure why I am not successful. Few Listed below.
https://www.autohotkey.com/docs/Objects.htm#Usage_Associative_Arrays
https://www.autohotkey.com/board/topic/77221-associative-array-of-objects-help/
https://www.autohotkey.com/board/topic/80057-insert-for-associative-arrays/
viewtopic.php?t=61349
https://www.autohotkey.com/board/topic/68585-ahk-l-associative-array-insertremove/
Your help is appreciated. Thank you.