[comp.sys.mac.hypercard] limit on script size?

czerny@cpsvax.cps.msu.edu (Barbara J. Czerny) (08/20/89)

Does anybody know if there is a limit on the size a script can be in a
card background?  Whenever I try to add something new to my background
script I get a boing for each character I add.  Also, if I copy a block
of text, I am unable to paste it in - again I get a boing.

Any help would be greatly appreciated.  Please mail reply to:
   Czerny@cpsvax.cps.msu.edu

Athos@cup.Portal.com (Rick Eames) (08/21/89)

In article <4243@cps3xx.UUCP> czerny@cpsvax.cps.msu.edu (Barbara J. 
Czerny) writes:
> Does anybody know if there is a limit on the size a script can be in a
> card background?  Whenever I try to add something new to my background
> script I get a boing for each character I add.  Also, if I copy a block
> of text, I am unable to paste it in - again I get a boing.


32K.

Rick Eames

ba0k+@andrew.cmu.edu (Brian Patrick Arnold) (08/22/89)

Hi there,

I think script sizes are safest at around 20k because HyperCard can run out of 
memory trying to execute big complicated handlers in big complicated scripts. 
Around 31k opening a script gives you a warning "beep", and around the 32k it
beeps if you try to type real close to the limit, and won't add text beyond a
point if you continue to type or paste text.  32k seems like the limit.
Type "the number of chars in script of <object-name>" in the message box to
find out how much space a given <object-name>'s script is taking up.

I do have a suggestion for you that may help.  To balance a need to reuse
handlers in heterogeneous places (button, card, bkgnd) without overburdening
bkgnd or stack scripts, I've adopted a strategy of creating objects that are
pseudo-object-classes and having bkgnd/stack handlers redirect calls to those
objects, significantly freeing up space and reusing code.

For example, I have file I/O handlers that can't fit with the rest of my stack
script, but I need to call these transparently from other cards.  So I have
"public" handlers in the stack script designed solely to redirect the handler
to the I/O card object script.  For a given handler as an example:

ON Foo x,y
  RETURN x*y
END Foo

I'd put this handler into a card button script "Bar", q.v., and have the
following *stack* handler:

ON Foo x,y
  SEND "Foo x,y" to cd btn "Bar"
END Foo

Of course this example doesn't save script space, but you get the point.

Passing the variable names in quotes suprisingly prevents them from being
interpreted until the card button handler gets them, which is a powerful
trick in using this method.  As a matter of fact, you could even write
handlers to be almost-truly object oriented using this method, by writing
classes that override and inherit handlers, calling appropriate scripts
and having "Method" and "Inherited" handlers in your stack to figure
out class names and methods.

But it would be nicer if the HyperTalk language and editor were more
object oriented like the rest of HyperCard already is, so we  wouldn't have
to resort to the use of other object's scripts in order to free up space.

- Brian