How to check if a group contains a specific control ?

Curry Kenworthy curry at pair.com
Sun Aug 25 19:01:12 EDT 2024


jbv:

 > Is there a quick way to check if a group contains a specific control,
 > something like : if there is a fld "xyz" in grp "abc" of this cd
 > I tried many things but it always generates an error.

Here is an easy and elegant way - almost what you started with!
The key is 'of' versus 'in'. They are not quite the same.

Try this - tested Win/Mac, LC 9.6:

if there is a field "xyz" of group "abc" of this card then answer "xyz"
put there is a field "xyz" of group "abc" of this card & cr after t

For objects/controls, 'of' is the correct syntax.
But 'in' is mainly used for text. Not a safe substitute here!

(The Message Box may just ignore everything after 'in' -
testing only for a field "xyz". That can confuse about 'of' and 'in'.)

The Script Editor will actually error, since 'in' is unexpected.

Happy coding...

Curry Kenworthy

Radically Innovative Christian LiveCode Development
"PASSION for Elegant, Efficient Code!"
https://livecodeconsulting.com/



More information about the use-livecode mailing list