gavinbaumanis
12/08/2022, 2:49 PM<cfscript>
myArray = ["myObj1", "myObj2", "myObj3"];
myResultsArray = [];
loop item="item" index="i" array=myArray {
"myStruct#i#" = {};
// run some function here for result Z. "item.someFunction()"
z = "myVal_I_got_back";
structInsert(evaluate("myStruct#i#"), "theZ", "#z#");
structInsert(evaluate("myStruct#i#"), "someOtherStuff", "MoreStuff");
arrayAppend(myResultsArray, evaluate("myStruct#i#"));
}
dump(myResultsArray);
</cfscript>
It works - but I would like to avoid evaluate(), if I can.
Instead of structInsert()
I tried
myStruct#i#.theZ =
myStruct#i#[thez] =
myStruct#i#["theZ"] =
myStruct#i#.[theZ] =
mystruct#i#.["theZ"] =
and also tried all of those again but quoting the start;
"myStruct#i#".theZ =
"myStruct#i#"[theZ] =
"mystruct#i#"...
And it kept complaining about using the "#" in the name portion...
Thanks.Michael Schmidt
12/08/2022, 2:50 PMMichael Schmidt
12/08/2022, 2:56 PMgavinbaumanis
12/08/2022, 3:02 PMvariables["myStruct" & i]["theZ"] = "#z#";
nonetheless - Thanks very much - for putting me straight!Michael Schmidt
12/08/2022, 3:03 PMaliaspooryorik
variables["myStruct#i#"]["theZ"] = z;Michael Schmidt
12/08/2022, 4:08 PMmyReference="myStruct" & i; // or myReference="myStruct#i#";
and then variables[myReference]["theZ"] = zthisOldDave
12/08/2022, 5:01 PMgavinbaumanis
12/09/2022, 12:51 AM.each()
Thanks!