generate an Array using value for naming the keys?

matthias_livecode_150811 at m-r-d.de matthias_livecode_150811 at m-r-d.de
Thu May 11 10:47:55 EDT 2023


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()  :) 

Regards,
Matthias

> Am 11.05.2023 um 16:36 schrieb Mark Waddingham via use-livecode <use-livecode at lists.runrev.com>:
> 
> On 2023-05-11 14:36, matthias rebbe via use-livecode wrote:
>> The middle part of the key names changes and there can be about 50 different "middle parts" and there are 10 main keys (after the middle part)
>> _content, _text _html and so on.
>> So without an idea i would have to create the code to fill all values for the array keys with the middle part aa and then the code  for the middle part cd and so on.
>> Is there a way to use value for this. So i could just add the middle part of the key name to a variable and use that then with value() to create and file the array?
> 
> Perhaps I'm misunderstanding what you are trying to do as you mention using value() for something which doesn't sound like it needs it...
> 
> Array keys can be arbitrary (string-valued) expressions - i.e. they don't have to be literal strings:
> 
> e.g. put tFoo["wp_" & tMiddlePart & "_" & tSuffix] into tMiddlePartSuffixValue
> 
> Warmest Regards,
> 
> Mark.
> 
> -- 
> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
> LiveCode: Build Amazing Things
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list