how to get the value of a custom property if the name of the cProperty is in a variable?

Bob Sneidar bobsneidar at iotecdigital.com
Tue Aug 8 12:04:49 EDT 2017


I agree here with Mark that this is an oversight, an aberration. It should't work the way it presently does, and I would not count on it being this way forever. Some other issue may arise in the future requiring someone to "fix this" and your code will break. 

Swim away from the other fish if you like, but beware of the sharks lurking about. 

Bob S


> On Aug 8, 2017, at 09:00 , Mark Waddingham via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Perhaps I'm misunderstanding your point here, but I think array syntax actually helps justify why the current behavior is wrong. Compare:
> 
> put 100 into redvalue
> put 0 into myArray[redvalue]
> put 255 into myArray["redvalue"]
> 
> To:
> 
> put 100 into redvalue
> set the redvalue of me to 0
> set the "redvalue" of me to 255
> 
> In the first case you get an array { 100: 0, redvalue: 255 }.
> 
> In the second case the customprops array is { 100: 255 }.
> 
> Basically everywhere else quoted literals evaluate to the quoted value - unquoted literals might evaluate to the contents of a variable if that variable has been created. In this case (in 'the ... of ...'), though, the quoted literal gets treated as if it doesn't have quotes all the time.
> 
> Warmest Regards,
> 
> Mark.
> 
> -- 
> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps





More information about the use-livecode mailing list