[comp.sys.mac.hypercard] Global variables from XCMD/XFCN

pkahn@meridian.ads.com (Phil Kahn) (06/17/88)

I got the Hypercard Script Language Guide from APDA along with the 
Hypercard Developer's Toolkit ($30 total) and together they provide
enough information to effectively write XCMD/XFCNs.

Problem is, the Language Guide states that XCMD/XFCN cannot use global
variables.  Though globals are sloppy, they are sometimes justified.
For example, I want to drive a digitizer board from hypercard.  There
is board base address and status information that is best kept global
without explicit reference from hypercard.  How can I do this?  Or do
I need to pass pointers back to hypercard.  Since hypercard wants
strings, I'd have to coerce to string and back to pointer on the next
call.  It seems this would only work for pointers to scalars. I can't
see how pointers to records/structs would work from the hypercard side.

All pointers :-) are appreciated.

phil...

dan@Apple.COM (Dan Allen) (06/22/88)

In article <4432@zodiac.UUCP> pkahn@ads.com (Phil Kahn) writes:
>Problem is, the Language Guide states that XCMD/XFCN cannot use global
>variables.  Though globals are sloppy, they are sometimes justified.
>For example, I want to drive a digitizer board from hypercard.  There
>is board base address and status information that is best kept global
>without explicit reference from hypercard.  How can I do this?  Or do
>I need to pass pointers back to hypercard.  Since hypercard wants
>strings, I'd have to coerce to string and back to pointer on the next
>call.  It seems this would only work for pointers to scalars. I can't
>see how pointers to records/structs would work from the hypercard side.

XCMDs currently do not have their own A5 World, which means that they do
not have a jump table (no code segmentation) and they do not have global
data.  Sorry.

Dan Allen
Apple Computer

DN5@PSUVM.BITNET (D. Jay Newman) (06/24/88)

A reply to David Allen, about XCMDs and XFNCs not having their own A5 world.

There are ways to manage global storage without A5.  Both Desk Accessories and
cdev's manage this easily, without an A5 world.  Each time one of the above
are called, one of the parameters they are passed is a handle.  Initially
it is 0, but they can load a handle to something in it, and pass it back
to the calling program.  Its a bit of a pain to program, because you have
to load all your global variables into a record, and access this record from
your handle, but it can be done.

My question: why wasn't this done with HyperCard?

                               Jay, etc...

ps.
  As long as I am asking questions, why do HyperCard scrolling fields differ
from every other scrolling field on the Mac: that is, when all the contents of
a scrolling field are visible, then the scrollbar is white.  In HyperCard, the
there is always a thumb on a grey scrollbar!