[comp.sys.mac.hypercard] Hierarchical stack buttons

lrasmuss@nmsu.edu (Linda Rasmussen) (02/14/90)

Does anyone know of an easy way to create UP and NEXT buttons in a very large 
hierarchical stack?  It looks something like this:

         a                a                  a
     b       b         b       b         b        b
   c c c   c c c     c c c   c c c     c c c    c c c

There are at least a hundred "a" cards; what we need is for UP arrow
buttons to go up to the parent "b" if they are a "c", or up to the 
parent "a" if they are a "b". We also need the NEXT arrows to go to
the next "a" if they are on an "a" card, the next "b" if they are on a 
"b" card, etc.  Obviously this can't be done with background arrows!
...But it is rather time consuming to have to script the up and 
next arrows on EVERY card.

Has anyone ever had to do this?  Did you come up with any brilliant
shortcuts?  

Thanks for any suggestions!



         Linda Rasmussen                     lrasmuss@nmsu.edu
         New Mexico State University           (505)646-5598

SAS102@psuvm.psu.edu (Steven A. Schrader) (02/14/90)

In article <529@opus.NMSU.EDU>, lrasmuss@nmsu.edu (Linda Rasmussen) says:
>
>Does anyone know of an easy way to create UP and NEXT buttons in a very large
>hierarchical stack?  It looks something like this:
>
>         a                a                  a
>     b       b         b       b         b        b
>   c c c   c c c     c c c   c c c     c c c    c c c
>
You could set a variable called LastCard.  When you leave the parent card,
you "Put the id of this card into LastCard" then on the up arrow you "Go cd
id LastCard"  The down buttons would have to be scripted though ...
-------
                    Steven A. Schrader
              (SAS102@Psuvm       SAS@Psuarch)
_________________________________________________________________________
                    227C Computer Building
                    The Pennsylvania State University
                    University Park, Pa. 16802
                    Phone : (814) 865 - 2160

                     343 Strouse Ave.
                     State College, Pa. 16803
                     (814)  237 - 8196

jtw@wuee1.wustl.edu (Trent Wohlschlaeger) (02/15/90)

In article <529@opus.NMSU.EDU> lrasmuss@nmsu.edu (Linda Rasmussen) writes:
>
>Does anyone know of an easy way to create UP and NEXT buttons in a very large 
>hierarchical stack?  It looks something like this:
>
>         a                a                  a
>     b       b         b       b         b        b
>   c c c   c c c     c c c   c c c     c c c    c c c
>
>There are at least a hundred "a" cards; what we need is for UP arrow
>buttons to go up to the parent "b" if they are a "c", or up to the 

I did this a while ago.  I ended up creating a bg named "a", a bg named "b",
and a bg named "c".  Reserve characters 1 to 25 of the name of each card
for a unique name, then use char 26 as an index for the b cards, and char 27
as an index for the c cards.

Now the script of your "up" button for bg "b" needs to be something like:

on mouseUp
  get the name of this cd
  put char 1 to 25 of it into aCard
  go to cd aCard of bg "a"
  -- do whatever error checking you like here....
end mouseUp

and similarly for "up" btn for bg "c"

The "next" button is much easier:

on mouseUp
  go next cd of this bg
end mouseUp

In my application, there was a problem with ensuring unique names, so I
eventually went to a single card, and toggled the visibility of the
fields and buttons to achieve the same effect.

Hope this helps,

Trent

tim@hoptoad.uucp (Tim Maroney) (02/16/90)

In article <529@opus.NMSU.EDU> lrasmuss@nmsu.edu (Linda Rasmussen) writes:
>Does anyone know of an easy way to create UP and NEXT buttons in a very large 
>hierarchical stack?  It looks something like this:
>
>         a                a                  a
>     b       b         b       b         b        b
>   c c c   c c c     c c c   c c c     c c c    c c c
>
>There are at least a hundred "a" cards; what we need is for UP arrow
>buttons to go up to the parent "b" if they are a "c", or up to the 
>parent "a" if they are a "b". We also need the NEXT arrows to go to
>the next "a" if they are on an "a" card, the next "b" if they are on a 
>"b" card, etc.  Obviously this can't be done with background arrows!
>...But it is rather time consuming to have to script the up and 
>next arrows on EVERY card.

There have been some other suggestions, but one limited the names of
cards and the others assumed that you would always traverse the stack
in hierarchical order, which could be violated by the "Back" and
"Recent" commands and by use of the message box to give direct "go"
commands".

I think the easiest way is to have a hidden background field in the C
cards (I'm assuming A, B, and C are different backgrounds -- they
should be) containing the name or id of the parent card.  Then you just
have the next button equate to "go to background field Parent".  You
can set up up short-term scripts that make it easy to to set this
field, by actually moving to a card rather than by typing, during the
stack authoring process.

As for the next buttons, they're trivial if A, B, and C are different
backgrounds.  "Go to next card of this background" accomplishes what
you need.  It's more difficult, but not enormously, if you want the C
cards to "next" by parent rather than as one continuous circle; you
just have to check the hidden field and keep going until you come back
to one with the same parent as the current card.

By the way, the parent field doesn't have to be hidden.  Users might
appreciate a visual indication of the parent of the current card.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

FROM THE FOOL FILE:
"American women, especially some of those on the net, might profit by being
 less concerned with their careers and more concerned with getting a good,
 old fashioned roll in the hay."
	-- William J. Fallon, wjf@cbnews.att.com, on soc.women
	  (also uses the alias Walter J. Ficklestein)

ccc_ldo@waikato.ac.nz (02/16/90)

Another solution would be to adopt a systematic naming convention for
your cards. That is, each card takes the name of its parent, to which
it appends something extra unique to this level.

Say you've got three layers in the hierarchy: a (the "root" level), b,
and c (the "leaf" level). The root-level cards are named "a1", "a2" etc.
The cards at level b are named "a1 b1", "a1 b2" etc. And the ones at
level c are similarly named "a1 b1 c1", "a1 b1 c2" etc.

Then your "up one level" button script becomes something like

	On MouseUp
	    Get the short name of this card
	    Delete last word of it
	    Go to card it
	End MouseUp

If all your cards share the same background, then the background
should contain an OpenCard script, somewhat as follows:

	On OpenCard
	    Get the short name of this card
	    Set visible of background button "Up one level" to \l
		(the number of words in it = 1)
	End OpenCard

(insert the appropriate continuation character in place of "\l").
This hides the button if you're already on a root-level card.

Hope this works.