[comp.sys.mac.hypercard] Checking for a named object sans error if nonexistant

bowden@csd4.csd.uwm.edu (John William Bowden) (08/08/90)

I have a stack that creates other stacks and I need to verify whether
certain stacks were so created. In order to do this I placed a hidden
field in the first card and gave it a unique name, then when I need to
open this stack with the creator stack for editing, it checks whether
the name of card field number x is "unique name". I need to do this
without generating an error if there is no card field number x in the
target stack...Do you know what I mean?

	domenu "Open Stack..."
	put name of cd fld x into theName --where x is an integer
	--I cant have it just say "Never heard of cd fld x"
	--and I must take action on the cd fld's proper/improper naming
	--or cd fld x's nonexistence.
	go to this stack

If anyone has a way to side-step the error message or knows of another
nifty way for checking for a named object's existence in another stack,
I would appreciate hearing from them via e-mail.
			Thanks In Advance,
			John W. Bowden

______________________________________________________________________
* John W. Bowden                     * bowden@csd4.csd.uwm.edu       *
* Computer Specialist                * INTERNET                      *
* UW-Milwaukee                       * "It's hard to work in groups  *
* Language Resource Center           *  when you are omnipotent."    *
* P.O. Box 413 Milwaukee, WI 53201   *                   -Q          *
* (414) 229-4447                     *                               *
----------------------------------------------------------------------

bc@Apple.COM (bill coderre) (08/08/90)

John Bowden:
|I have a stack that creates other stacks and I need to verify whether
|certain stacks were so created. 
There's an XFCN called "FileExists" in the Developer Stack 1.3.
It may be all you need. 

I'll summarize his second question:
"Is there a way to determine whether a certain (object) exists?"

Well, in HC 1.x, no. 

There should be a rather general gestalt tester in 2.0, so phrases
like:
	if there is a cd btn "foo" then ....
and
	if there is no menu "bar" then ....
will be available.


bill coderre, consultant to Apple

englfz@jetson.uh.edu (08/14/90)

In article <43714@apple.Apple.COM>, bc@Apple.COM (bill coderre) writes:
> John Bowden:
> |I have a stack that creates other stacks and I need to verify whether
> |certain stacks were so created. 
 
> I'll summarize his second question:
> "Is there a way to determine whether a certain (object) exists?"
> 
> Well, in HC 1.x, no. 
> 
> bill coderre, consultant to Apple

The way I check to see if an object (field, button or something) exists
and then get its name looks something like the following:

	on checkfield
	  if the number of card fields > 0 then
          put the name of cd field 1 into fieldname
	end checkfield

With this approach, it only gets the name if a field exists, and therefore
won't give you the "Never heard of..." message if you are checking 
for the name of a nonexistant somethingorother.

Hope this helps


---------------------------------------------------------------------
 Ed Gibler                              University of Houston
 ENGLFZ@JETSON.uh.edu                English Computer Writing Lab
---------------------------------------------------------------------