[comp.sys.mac.hypercard] checking for field existence?

jcocon@hubcap.clemson.edu (james c oconnor) (04/04/91)

I would like to be able to check to see if a field by a particular
name exists.  Is this possible, or should I write an xcmd?

Jim

sahara@sran192.sra.co.jp (Shin Sahara) (04/07/91)

In article <1991Apr3.192733.28490@hubcap.clemson.edu> jcocon@hubcap.clemson.edu (james c oconnor) writes:
>I would like to be able to check to see if a field by a particular
>name exists.  Is this possible, or should I write an xcmd?
 You can test for the existence of something by "there is" operators.
The forms are:

there is a{n} <thing>
there is not a{n} <thing>
there is no <thing>
<thing> := <window> | <menu> | <menuItem> | <file> | <button> | <field> |
<card> | <background> | <stack>

So you can say:
 if there is not a field "money" then makeMoney

	103kg

leue@galen.crd.ge.com (Bill Leue) (04/08/91)

In article <1991Apr3.192733.28490@hubcap.clemson.edu> jcocon@hubcap.clemson.edu (james c oconnor) writes:
>I would like to be able to check to see if a field by a particular
>name exists.  Is this possible, or should I write an xcmd?
>
>Jim

I asked a similar question a couple of weeks ago and got lots of good
replies, so here's my chance to pay back my debt.

HC 2.0 (not earlier versions!) have a "there is" operator which will
do what you want.  An example for detecting a field on the current card:

if there is a card field "Foo" then...

You can easily extend this to detecting a field in the entire stack,
or any object (button, window, etc) using standard looping techniques.

-Bill Leue
leue@crd.ge.com