[comp.sys.mac.hypercard] Existance of a card

irwin@oscar.ccm.udel.edu (11/15/89)

  Hello friends,
	I am having a problem.  I need to check for the existance of a card.
I cannot 'go' to the card and check the result because I need to do the check
in a closeCard handler.  This has probably been discussed before but I cannot
keep up with all these groups and get any work done.  I am really supprised 
that there isn't a function 'the item exists' that would return true if the
item was valid.  I have poured over my literature for two days now and I would
rather not brute force it.

Thanx for your assistance

Rich Irwin
irwin@oscar.ccm.udel.edu
Center for Composite Materials
University of Delaware
Newar, DE 19716

taylorj@yvax.byu.edu (11/21/89)

Easiest solution is to get SuperCard, which has an "exists" function.  (I
really do hope this will be added to HyperCard 2.0).

Not so easy but more practical solution is something like this:

  put false into cardExists
  repeat with c = 1 to the number of cards
    if the short name of card c = <the name of the card you're looking for> then
      put true into cardExists
      exit repeat
    end if
  end repeat

If this is what you meant by "brute force it," then I'm afraid you're out of
luck.


Jim Taylor
Microcomputer Support for Curriculum
Brigham Young University
taylorj@yvax.byu.edu

psych@watserv1.waterloo.edu (R.Crispin - Psychology) (11/22/89)

A solution to the existance of a card that is short would be
 
	set lockscreen to true
	put the id of this card into oldiddrad
	go to card cardname
	if the result is not empty then
                -- The card was not found
		--do what ever you want here
		go to card oldid
	else
		-- You will be at the card cardname
		-- Do what ever you want here
	end if
	set lockscreen to false

Hope this helps
 
Richard Crispin
Dept. of Psych
Univ. of Waterloo
Waterloo, Ontarioo

tim@hoptoad.uucp (Tim Maroney) (11/24/89)

In article <195@watserv1.waterloo.edu> psych@watserv1.waterloo.edu
(R.Crispin - Psychology) writes:
>A solution to the existance of a card that is short would be
> 
>	set lockscreen to true
>	put the id of this card into oldiddrad
>	go to card cardname
>	if the result is not empty then
>		go to card oldid
>	else
>		-- Do what ever you want here
>	end if
>	set lockscreen to false

This does not answer the original question, since it will not work in a
closeCard script -- it will recurse indefinitely.  I have been watching
the discussion and I've been wondering why no one pointed out that if
you also "set lockMessages to true", then you should be able to get
away with scooting over to another card, then scooting back, with no
problems in a closeCard script.  Am I overlooking something?
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

Feminism that refuses to use the word "patriarchy" is kin to abolitionism
that refuses to use the word "slavery".

mmt@client1.DRETOR.UUCP (Martin Taylor) (11/24/89)

The dartmouth Xcmd stack (v3.1) has an ObjectExists XFCN that can tell
whether an object of a type known to HC exists (card, button, field, stack)
This is a much needed function if you are going to do repetitive things
on cards of different shapes.  The stack is in the sumex archives for
ftp access.
-- 
Martin Taylor (mmt@zorac.dciem.dnd.ca ...!uunet!dciem!mmt) (416) 635-2048
If the universe transcends formal methods, it might be interesting.
     (Steven Ryan).