Thanks for the replies.
RUNIE wrote:Could you show how you made the array in the first place?
Sure. This is the assignment used to create it (within a parsing loop):
Code: Select all
arraySet_%stringTempAbbrev%_%stringFileDate%.Insert((stringTempKeyName),(stringTempValue))
stringTempKeyName and
stringTempValue are string variables constructed beforehand within the loop.
This creates an object like 'arraySet_ABC_20070720' and key 'key_Name_Goes_Here'.
When I am retrieving my values from the keys, I am trying to do it within another similar loop that again constructs the correct array object name and keynames before I try to use them.
I know one method is to loop through the entire object (
for S_KEY,S_VAL in obj...), stopping when I hit my keyname, and pulling out the value, but since I have hundreds (and potentially thousands) of keys I don't really want to do this if I can avoid it.
jeeswg wrote:Code: Select all
q::
oArray := {abcde:"ABCDE"}
vTemp := "bcd"
MsgBox, % oArray["a" vTemp "e"]
oArray := ""
return
Ahh. I think this looks promising! The syntax of how AHK wants me to form my keynames with variables wasn't clear to me! For me it's more like
Code: Select all
oArray := {foo_BarData1:"ABCDE"}
vTemp := "foo_Bar"
vTemp2 := "Data1"
value:= oArray[vTemp vTemp2]
This seems to work in a quick test. I'll try and implement this later. Thanks very much
Would it be possible for you to explain this line in the second example? I can't quite get my head around this syntax! (There's two assignments on the same line?)
jeeswg wrote:Code: Select all
(oArray := {})["abc","def","ghi"] := "hello"
Yeah I read that thread, it seemed to be close to what I was asking but I'll be honest I couldn't make sense of any of the examples!