HyperCard: Variable Space


HyperCard 1.1 limits the programmer to 255 global variables. When writing
complex stacks, you can run out of variable space. This does not mean
you've used your allotted 255 variables. It can mean that the amount of
data you've put into the variables exceeds available memory. If you run
into this problem, you three things you can do:

First, rethink your use of variables. Can you redesign so that you don't
need so many?

Second, you can put empty into a global variable and increase space for
other global variables.

Third, if you really need more than 255 global variables, there is a
workaround. The following script demonstrates how you can reduce the number
of global variables by treat a variable as two-dimensional array:

on mouseUp
global globalVar
put "Test" into item 32 of line 1000 of globalVar
put " it worked!!" into item 1 of line 1 of globalVar
put item 32 of line 1000 of globalVar into item 1 of localVar
put item 1 of line 1 of globalVar into item 2 of localVar
put line 1 of localVar into msg
end mouseUp

This example, which creates a global variable, "globalVar," having 32,000
elements, shows a more economical handling of variables. Note: A variable
can contain only 32,767 characters.


Published Date: Feb 18, 2012