generate an Array using value for naming the keys?

Mark Waddingham mark at livecode.com
Thu May 11 10:51:09 EDT 2023


On 2023-05-11 15:47, matthias rebbe via use-livecode wrote:
> Mark, thank you very much!
> 
> i didn't know or remember that the key name of an array can be created 
> directly using strings and variables
> 
> Maybe i even did that in the past, but could not remember anymore. I 
> really thought i have solved it that time with value()  :)

No problem - of course, I used & in my example - but when I'm doing 
stuff like that I tend to use format:

put tFoo[format("wp_%s_%s", tMiddlePart, tSuffix)] into 
tMiddlePartSuffixValue

It does the same job, but I find it more readable (as the structure of 
the string can be seen immediately without having to wade through quotes 
and ampersands :)

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Build Amazing Things



More information about the use-livecode mailing list