Re: generate an Array using value for naming the keys?

2023-05-11 Thread matthias rebbe via use-livecode
Thanks for this also. I will keep that in mind, but for now i will use the & 
syntax.

Format() is also a function i often struggle with. ;)

> Am 11.05.2023 um 16:51 schrieb Mark Waddingham via use-livecode 
> :
> 
> 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 ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Build Amazing Things
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: generate an Array using value for naming the keys?

2023-05-11 Thread Ralph DiMola via use-livecode
Mark,
I will start doing this. I have a headache just thinking of the last time I
had some complex keys and trying to read the code with the afore mentioned
quotes and ampersands. Learn something new every day. 

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of Mark Waddingham via use-livecode
Sent: Thursday, May 11, 2023 10:51 AM
To: How to use LiveCode
Cc: Mark Waddingham
Subject: Re: generate an Array using value for naming the keys?

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 ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Build Amazing Things

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: generate an Array using value for naming the keys?

2023-05-11 Thread Mark Waddingham via use-livecode

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 ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Build Amazing Things

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: generate an Array using value for naming the keys?

2023-05-11 Thread matthias rebbe via use-livecode
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 
> :
> 
> 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 ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Build Amazing Things
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: generate an Array using value for naming the keys?

2023-05-11 Thread Mark Waddingham via use-livecode

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 ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Build Amazing Things

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


generate an Array using value for naming the keys?

2023-05-11 Thread matthias rebbe via use-livecode
Hi,

once in a while i am struggling with value(). ;) 

I have the following problem.
I need to create an array which keys are something like this

wp_aa_old
wp_cd_old
wp_ek_old
wp_aa_new
wp_cd_new

and so on.

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?

I think i have done this before, but i might be wrong.

Regards,
Matthias


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode