[comp.sys.mac] HyperCard question

chuq%plaid@Sun.COM (Chuq Von Rospach) (10/05/87)

I'll bet this will turn out to be a real simple question, but here goes. I'm
starting to work with Hypercard, and I'm trying to put together a pretty
simple application, but I'm not sure how to build a linked list of cards
attached to a primary card.

The basic design is this. I've got a stack of cards. For each card in the
stack, I may have zero or more cards that I want to attach to it. The
primary card should have a count of the number of cards attached to it as
well as a way of looking at each of the cards.

Any suggestions? I'm sure this is pretty trivial, but I haven't had a lot of
time to hack hypercard yet.

chuq

Chuq Von Rospach					chuq@sun.COM
Editor, OtherRealms					Delphi: CHUQ

Bye bye life!  Bye bye happiness! Hello, loneliness, I think I'm gonna die.

cs162fed@sdcc18.ucsd.EDU (Grobbins) (10/05/87)

In article <29942@sun.uucp> chuq%plaid@Sun.COM (Chuq Von Rospach) writes:
>..I'm not sure how to build a linked list of cards attached to a primary card.
>
>The basic design is this. I've got a stack of cards. For each card in the
>stack, I may have zero or more cards that I want to attach to it. The
>primary card should have a count of the number of cards attached to it as
>well as a way of looking at each of the cards.

It sounds like Chuq could use a field in each card or background with 
the first line holding the number of linked cards and the names or 
id numbers of the linked cards in the following lines of the field,
but this brings up a problem that I've been having:

I'm trying to go to cards by a name composed of a string constant
and a variable number, as in

  go to card "Sheetnum"&snum    -- and variants, incl. putting "x"&y in parens

but Hypercard usually fails to go to the proper, or any, card.
This occurs only (or primarily) in scripts; if I execute the same
line in the message window, Hypercard takes me to the proper card
without complaining.  Have I overlooked some requirement of the
go command, or can anyone suggest some other likely oversight on my 
part?


Grobbins              cs162fed@sdcc18.ucsd.edu
                      ..sdcsvax!sdcc18!cs162fed

sysop@stech.UUCP (Jan Harrington) (10/05/87)

in article <29942@sun.uucp>, chuq%plaid@Sun.COM (Chuq Von Rospach) says:
> 
> The basic design is this. I've got a stack of cards. For each card in the
> stack, I may have zero or more cards that I want to attach to it. The
> primary card should have a count of the number of cards attached to it as
> well as a way of looking at each of the cards.
> 
Cards in a HyperCard stack are linked in a linear fashion.  In other words,
there are no one-to-many relationships.  There's no problem with attaching 
the count of the number of cards in a string to a primary card, but the
other cards have a first/next order; they aren't arranged in a fan-like
set-up.               

The card count can be part of a script attached to the primary card, but you
may find that you don't need it. A simpler strategy is to 
put a button on the primary card for each card in the list that you
want to reach directly from the primary card (i.e., not in first/next
order).  There are two ways then to set up the transfer.  You can link the
button to the card or you can write a simple script attached to the button
which simply goes to the required card (either by name or ID#).  Personally,
I prefer the latter, using names, because it requires fewer changes as the
stack changes.  My buttons all "go to card x", where x is the name of card.
This way, if I move things around in the stack I don't have to worry about
situations where links may become invalid. Card names are more informative
than id #'s; they form a sort of self-documentation.

Hope this answers a few questions.  (?)

Jan Harrington, sysop
Scholastech Telecommuications
ihnp4!husc6!amcad!stech!sysop or allegra!stech!sysop

kerpelma@macbeth.steinmetz (dan kerpelman) (10/05/87)

In article <29942@sun.uucp> chuq%plaid@Sun.COM (Chuq Von Rospach) writes:
>I'll bet this will turn out to be a real simple question, but here goes. I'm
>starting to work with Hypercard, and I'm trying to put together a pretty
>simple application, but I'm not sure how to build a linked list of cards
>attached to a primary card.
>
>The basic design is this. I've got a stack of cards. For each card in the
>stack, I may have zero or more cards that I want to attach to it. The
>primary card should have a count of the number of cards attached to it as
>well as a way of looking at each of the cards.
>
>Any suggestions? I'm sure this is pretty trivial, but I haven't had a lot of
>time to hack hypercard yet.
>
>chuq
>

It sounds as if you need a stack of stacks, not a stack of cards.  In other
words, you could have a bunch of stacks that belong to a "superstack".  The
background of the superstack should define forward and backward buttons that
allow navigating among the primary cards of each aggregate stack.  The primary
card of each aggregate stack should define additional buttons enabling browsing
through its cards.  You could even put in a fast browse button.  Copy it from
one of the provided stacks if you don't know advanced HyperTalk.

To know how many cards are in a stack, you can define a button in its primary
card that performs a HyperTalk "domenu stack info".  This will bring up the
stack information menu.

Try browsing the provided stacks.  It's likely you'll find a similar
application.  You can copy this and use it as a template for developing your
own.  Have fun.





 
----------------------------------------------------------------------------
Dan Kerpelman                      ARPAnet  :  kerpelman@ge-crd.arpa
GE Corporate R&D                   GE DECnet:  ctsvax::kerpelman
Schenectady, NY, USA               telephone:  (518) 387-5086

freedman@calgary.UUCP (Dan Freedman) (10/05/87)

In article <29942@sun.uucp>, chuq%plaid@Sun.COM (Chuq Von Rospach) writes:
> ... but I'm not sure how to build a linked list of cards
> attached to a primary card.

Well, for any linked list, all you need is to store a pointer to the next
element somewhere in the current element.  In HyperCard, the "pointer" is
the card id of the next card (a number like '12345'),
and you may as well store it in a field on each card in your list (perhaps
called "next card").  You can make the card invisible by issuing the 'hide 
field "next card"' command in the message window (this only need be done once.
Once the field is hidden, it will stay hidden until you issue a 'show field
"next card"' command).  You should probably also tick off the "lock text"
option for that field so that users can't change it's contents even if they
manage to make the field visible (you can still change the field's contents
from a script, even if lock text is switched on).  

Getting the name of the next card is quite easy if you create the cards from
a script:  something like this excerpt should do the trick.

	...
	put the id of this card into oldcard
	doMenu "New Card"
	put the id of this card into field "next card" of card id oldcard
	-- note that "this card" changes during the doMenu "New Card" command.
	...

The excerpt should be inserted in whatever script creates new cards for your
linked list.  Multiply linked lists can be handles in a similar fashion.
If your list must link cards across stacks, then you must also store the
name of the stack as well as the id number of the card.  The command
"this stack" will return the name of the current stack.

I hope this is helpful.

	Dan Freedman.
	University of Calgary Computer Science Department.

freedman@calgary.UUCP (Dan Freedman) (10/06/87)

In article <774@sdcc18.ucsd.EDU>, cs162fed@sdcc18.ucsd.EDU (Grobbins) writes:
> I'm trying to go to cards by a name composed of a string constant
> and a variable number, as in
>   go to card "Sheetnum"&snum    -- and variants, incl. putting "x"&y in parens
> but Hypercard usually fails to go to the proper, or any, card.
> This occurs only (or primarily) in scripts; if I execute the same
> line in the message window, Hypercard takes me to the proper card
> without complaining.

Hmm, I went to the home stack, and tried the following:
	CMD-2 (to get away from the home card)
	put "e" into f
	go to card "hom"&f

from the message box.  It did not work.  I then tried:
	go to card "hom" & e 
(note the spacing).  It worked.  I then made a button in the card before the home card
and put the following into the script:
	on mouseUp
		put "e" into f
		go to card "hom" & f
	end mouseUp

and tried the button.  It worked perfectly.  Could it be that you are having
problems because of the way you are spacing your arguments?  What do you mean when
you say that HyperCard "usually" fails?  I tried my button 5 or 6 times, and it
worked each time.  

	Dan Freedman
	University of Calgary Computer Science Department

freedman@calgary.UUCP (Dan Freedman) (10/07/87)

In article <7522@steinmetz.steinmetz.UUCP>, kerpelma@macbeth.steinmetz (dan kerpelman) writes:
> It sounds as if you need a stack of stacks, not a stack of cards.

The problem with stacks of stacks is the time tht it takes to switch between
them, especially on floppy, although having multiple stacks does seem like a
better solution conceptually.  Flipping between cards within stacks, on the other
hand goes fairly fast.

> To know how many cards are in a stack, you can define a button in its primary
> card that performs a HyperTalk "domenu stack info".  This will bring up the
> stack information menu.

Typing "number of cards" in the message window works too.

	Dan Freedman
	University of Calgary Computer Science Department

cs162fed@sdcc18.ucsd.EDU (Grobbins) (10/09/87)

In article <1098@vaxb.calgary.UUCP> freedman@calgary.UUCP (Dan Freedman) writes:
>In article <774@sdcc18.ucsd.EDU>, cs162fed@sdcc18.ucsd.EDU (Grobbins) writes:
>> I'm trying to go to cards by a name composed of a string constant
>> and a variable number, as in   go to card "Sheetnum"&snum
>> but Hypercard usually fails to go to the proper, or any, card.
>
>Hmm, I went to the home stack, and tried the following:
>	go to card "hom" & e
>(note the spacing).  It worked.  ...  Could it be that you are having
>problems because of the way you are spacing your arguments?  
>What do you mean when you say that HyperCard "usually" fails?  

I said 'usually' because it seemed intermittent, and I was ashamed to
admit I hadn't tracked it down.

I went to the problematic stack, put spaces before & after the
ampersand, and it worked perfectly.  I took away the spaces before
and after the &, and it still worked.  Aargh!  It might be
a problem with spacing around the ampersand, but I haven't been able
to prove that to myself.  Frustration city.

I hope you've found the problem for me, Dan...  I'll let you know if
I determine anything more conclusive.  Has anyone else run into this 
problem or other seemingly intermittent bugs in HyperTalk?


Grobbins                cs162fed@sdcc18.ucsd.edu
                        ..sdcsvax!sdcc18!cs162fed

winkler@apple.UUCP (Dan Winkler) (10/09/87)

HyperTalk, like C and Pascal, ignores spaces in valid expressions.  The
only time spaces become important is when the expression is invalid and
HyperTalk interprets it as an uquoted literal.  For example:

  go to stack clip art

is interpreted as

  go to stack "clip art"

Note that because stack names can only occur at the end of a line,
HyperTalk will accept multiple token unquoted literals.  In most
other cases, it will only take single token uquoted literals.  For
example:

  put field date into x

is interpreted as

  put field "date" into x

but 

  put field date of birth into x

would cause a syntax error because HyperTalk cannot recognize
multiple token unquoted literals within a line.  In general,
use of unquoted literals is strongly discouraged since if you
later define a variable of the same name then your script will
begin behaving differently.

kurt@doodah.UUCP (Kurt VanderSluis) (10/12/87)

I have multiple stacks that have corresponding cards.  I could, I suppose,
link each card one at a time, but since they each have a field with
identical info i would like to say something like:

get field "name"
find it in field "name" in stack "new"

instead I have to write:

get field "name"
go to stack "new"
find it in field "name"

The problem with this is that I make a short stop at the top card of
the new stack.  I would rather just zip to the card I want.

Is there a better way?  I've looked and I can't find it.
-- 
Kurt VanderSluis                   *********************************
Boeing Computer Services           *   These opinions are mine,    *
M/S 6R-37  P.O. 24346              *   not the Boeing Company's.   *
Seattle, WA  98124                 *********************************

mjkobb@mit-amt.MEDIA.MIT.EDU (Michael J Kobb) (10/01/89)

Hi, folks!  Wasn't there a DA once upon a time that would allow the user to
read a HyperCard stack without having to have the incredibly space-hogging
application on the hard disk?  If anyone can point me to it, please let me
know!

Thanks in advance!

--Mike

kent@sunfs3.camex.uucp (Kent Borg) (10/04/89)

In article <774@mit-amt.MEDIA.MIT.EDU> mjkobb@media-lab.media.mit.edu (Michael J Kobb) writes:
>Hi, folks!  Wasn't there a DA once upon a time that would allow the user to
>read a HyperCard stack without having to have the incredibly space-hogging
>application on the hard disk?  If anyone can point me to it, please let me
>know!

You want HyperDA from Symmetry Corporation.

They live at:

Suite 107
225 East First Street
Mesa, AZ 85201

Voice: (800) 624-2485 and (602) 844-2485   Fax: (602) 890-2541


Mind you, though this will let you read a HyperCard Stack, much of the
scripting will not be understood.  Complicated stacks won't work.

The newest version now allows you to edit text fileds, not just look
at them.

-- 
Kent Borg				"Then again I could be foolish 
kent@lloyd.uucp				 not to quit while I'm ahead..."
or					     -from Evita (sung by Juan Peron)
...!husc6!lloyd!kent