[comp.sys.mac.hypercard] double clicking on a stack - strange things happen

udi@cs.arizona.edu (Udi Manber) (12/07/90)

It seems that HC 1.2.x behaves differently when a stack is opened by
double clicking on it than when it is entered through Home (or another
stack).  My specific problem is that I want to set the userlevel when
a certain stack is opened.  When I double click on the stack (under
multifinder), the user level that is specified in my Home stack is set 
rather than the one the openStack procedure specifies.
There is no problem when I entered the stack through other stacks.
I really want users to be able to use this stack independently of what
they have in their Home stack.  Any ideas on hacks to overcome this
(apparent) bug (or hints on what I am doing wrong)
would be greatly appreciated.

-- Udi Manber  (udi@cs.arizona.edu) 
-- Dept. of Computer Science
-- University of Arizona
-- Tucson, AZ 85721

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (12/10/90)

In article <105@aloe.cs.arizona.edu> udi@cs.arizona.edu (Udi Manber) writes:
>It seems that HC 1.2.x behaves differently when a stack is opened by
>double clicking on it than when it is entered through Home (or another
>stack).  My specific problem is that I want to set the userlevel when
>a certain stack is opened.  When I double click on the stack (under
>multifinder), the user level that is specified in my Home stack is set 
>rather than the one the openStack procedure specifies.

What's happening is this. Under HyperCard 1.x, the messages sent when
HyperCard is launched are as follows:

  openStack
  openBackground
  openCard
  startup

Your userLevel is set in the openStack handler as usual, but then the startup
message is sent. The Home stack's startup handler calls a routine called
getHomeInfo which sets up the preferences the user has chosen. Thus, when
you double-click a stack and launch HyperCard, the user's own preferences
override your openStack handler.

Now, in general, it's not a good idea to override those preferences, any
more than to override Control Panel preferences such as sound level. However,
there are some times when you'll want to do this. If you want to ensure that
the userLevel will be no higher than a certain value, you can use the
Protect Stack item in the File menu to set a top level.

If you want to set a "floor" instead of a "ceiling", your task is a little
more difficult. The simplest solution is probably an idle handler in the
script of the first card:

  on idle
    global savedUserLevel  -- so you can restore user preference on closeStack
    if the userLevel < 3 then
      put the userLevel into savedUserLevel
      set the userLevel to 3
    end if
  end idle

In HyperCard 2.0, the message order is changed:

  startup
  openStack
  openBackground
  openCard

so this problem disappears in 2.0.
-- 
========= jeanne a. e. devoto ========================================
 jdevoto@apple.com     |  You may not distribute this article under a
 jdevoto@well.sf.ca.us |  compilation copyright without my permission.
______________________________________________________________________
 Apple Computer and I are not authorized      |        CI$: 72411,165
 to speak for each other.                     |