[comp.sys.mac.hypercard] Help a novice, please?

jdevoto@Apple.COM (Jeanne A. E. DeVoto) (04/07/90)

In article <47965@lanl.gov> bxb@lanl.gov (barry j. berenberg) writes:
>I have several stacks.  One is like a home card, the rest are
>identical excpet for the information contained in the fields (it's a
>kind of filing system).  The identical stacks contain several XCMDs
>and XFCNs.  It seems a waste to keep the resources in each stack
>(since they're all the same), so I'm trying to put them only in the
>main stack, and have the other stacks pass some sort of message to
>this stack (I'm trying to change the message hierarchy).
>So far, I haven't had any luck.

If the external "myXCMD" is in the resource fork of stack "Pseudo-Home",
sending "myXCMD" to that stack should find and execute the XCMD. If it's
not, maybe you could post a script fragment. (Note: if the XCMD uses
external resources such as STR#s or DLOGs, it's not clear to me whether
it will be able to locate these resources and function properly.)

XFCNs are a little more involved, since you can't "send" a function call.
When a handler contains a command to go to another card, that card's
message path -- the card, background, and stack scripts, and the stack's
resource fork -- are temporarily placed in the message path, right after
the executing stack and right before the Home stack. This is called the
dynamic path.

What this means:

If you go to another stack under script control, its resource fork will
be included in the message hierarchy. For example, if you do this:

  on mouseUp
    lock screen
    set the lockMessages to true
    go stack "Pseudo-Home"
    get myXFCN()
    go recent card
    set the lockMessages to false
    unlock screen
  end mouseUp

and the external "myXFCN" is in the "Pseudo-Home" stack, the above handler
will successfully find and execute it.

If your stacks share handlers and make up an integrated system, one other
possibility is to make your central stack into a real Home stack, so that
it operates as Home whenever users are using your stacks. Not knowing what
your project does, I can't say whether this might be appropriate here; but
it's often a good possibility, particularly in environments dedicated to a
single stack application.
-- 
====== jeanne a. e. devoto ========================================
 jdevoto@apple.com  |  You may not distribute this article under a
 jdevoto@well.UUCP  |  compilation copyright without my permission.
___________________________________________________________________
 Apple Computer and I are not authorized  |        CI$: 72411,165
 to speak for each other.                 |  AppleLink: SQA.TEST

bxb@lanl.gov (barry j. berenberg) (04/09/90)

First, I want to thank everyone for the responses they sent me.  Most
were of the type "put the resources in the Home stack," which is what
I ended up doing.  However, I plan to eventually distribute these
stacks and had wanted to avoid that.

> not, maybe you could post a script fragment. (Note: if the XCMD uses
> external resources such as STR#s or DLOGs, it's not clear to me whether
> it will be able to locate these resources and function properly.)

They do use DLOGs, and they didn't show up.  Evidently, the XCMD
wasn't able to locate them.

>   on mouseUp
>     lock screen
>     set the lockMessages to true
>     go stack "Pseudo-Home"
>     get myXFCN()
>     go recent card
>     set the lockMessages to false
>     unlock screen
>   end mouseUp

Now that I see it, this looks like a workable (and obvious!) solution.

Thanks for your help.

Barry Berenberg
bxb@lanl.gov