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

Mark Waddingham mark at livecode.com
Tue Aug 8 11:33:35 EDT 2017


On 2017-08-08 17:25, J. Landman Gay via use-livecode wrote:
> The answer to the first case is "don't do that". Use a different
> variable name for the local.

Well, yes, that is certainly one way to look at it!

However, *usually* quotes are used to ensure something is treated as
the literal value so my general feeling (since quoted property names
only work in some situations) is that this is actually an error, and was
never intended. Indeed, it comes down to *not* checking whether 
something
is an IDENTIFIER or a STRING in the parsing code before looking up a
variable.

(Of course, I'm now going to go off and see if you can use quoted
variables in other places - I bet that's going to a 50/50 chance in 
every
place!)

> The second case is interesting. I wouldn't mind having multiple-word
> property names.

Its not just that - it allows you to not have to use variable 
indirection
if your property names aren't identifiers too.

Of course, if were all good pandas we'd probably try and avoid using 
anything
other than (single) identifiers and were never the same as any local, 
script local
or global variable name...

Warmest Regards,

Mark.

> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> 
> 
> 
> On August 8, 2017 10:17:29 AM Mark Waddingham via use-livecode
> <use-livecode at lists.runrev.com> wrote:
> 
>> On 2017-08-08 17:09, J. Landman Gay via use-livecode wrote:
>>> In what circumstance would it be necessary to quote the property 
>>> name?
>> 
>> The original case Dr Hawkins encountered was something along the lines
>> of:
>> 
>> local someVar
>> put 100 into someVar
>> put the someVar of me
>> 
>> Here, this will fetch the custom property '100'. Ideally you'd be able
>> to do
>> 
>>    put the "someVar" of me
>> 
>> Instead - the quoting indicating you want to use that *literal* value
>> for the
>> property name, instead of the variables context.
>> 
>> Another case is wanting to fetch custom property names which contain
>> chars you
>> can't have in an unquoted literal:
>> 
>>    put the "my property name with lots of words (and parantheses) too" 
>> of
>> me
>> 
>> Currently, using quoted literals in this case works for setting, but
>> doesn't
>> work for getting; and even a quoted literal will still resolve to a
>> variable
>> if one has been defined.
>> 
>> I think the latter is probably something which is unlikely to hurt
>> anyone if
>> tweaked though...
>> 
>> Warmest Regards,
>> 
>> Mark.
>> 
>>> 
>>> On August 8, 2017 6:05:21 AM Mark Waddingham via use-livecode
>>> <use-livecode at lists.runrev.com> 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.
>>> 
>>> --
>>> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
>>> HyperActive Software           |     http://www.hyperactivesw.com
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> 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
>> 
>> --
>> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
>> LiveCode: Everyone can create apps
>> 
>> _______________________________________________
>> 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
> 
> 
> 
> _______________________________________________
> 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

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the Use-livecode mailing list