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

hh hh at hyperhh.de
Tue Aug 8 11:49:24 EDT 2017


> JLG wrote:
> In what circumstance would it be necessary to quote the property name?

Use "&" in a key, for example the "G&T" of me

> Mark wrote:
> What doesn't work at the moment is if you have a var name which is 
> quoted:
> 
> local catness
> put "minimal" into catness
> set the "catness" of me to "very much"
> get the customProperties of me
> put the keys of it
> 
> Will result in a key 'minimal' and *not* 'catness' - which is perhaps 
> not what would be expected.

From a viewpoint of the "get property /set property" syntax
"unexpected results" sounds convincing here, but, TMHO, it is
exactly what I would expect from a **viewpoint of array syntax**.

on mouseUp
  local catness
  put "minimal" into catness
  --> Then the next two lines
  set the minimal of me to "very much"    --(1)
  set the "minimal" of me to "very much"  --(2)
  --> are equivalent and create the same key "minimal".
  --> As catness is "minimal" and is NOT empty, this is also equivalent to
  set the catness of me to "very much"    --(3)
  --> what is, as usual when quoting, equivalent to
  set the "catness" of me to "very much"  --(4)
  --> Four equivalent commands (1)-(4) result in the same key "minimal".
  --> And it["catness"] is empty, correctly.
  get the customProperties of me
  put it["catness"] &"/"& it[catness] &"/"& it["minimal"] &"/"& it[minimal]
  put cr & the keys of it after msg
end mouseUp






More information about the use-livecode mailing list