Stack and Substacks and user properties

Richard Gaskin ambassador at
Sat May 31 13:22:02 EDT 2003

Stephen Quinn Barncard wrote:

There's more not addressed in the link I posted a moment ago:

> I got it. The bummer is that user properties have much less
> usefulness for me in a standalone. I might as well just continue to
> use variables for transitory data and user properties as constants --
> imbedded lists that don't change. What else are they good for?

General data storage.  Keep in mind that custom prps can be altered at
runtime even in a standalne, just not saved.  If you need them persistent
between sessions you can save them to a stack file outside the exe.

While there are many great uses for custom props, here's one unique benefit:
by binding arbitrary data to specific objects you get the benefits of global
vars but without the name space issues, and a whole lotta convenience comes
along with 'em.

For example, a useful design principle is to separate code, interface, and
data, and keep the connections between them to a minimum.  For a simple
example, most text editors store only the text from the main editing field,
and keep the user interface used for displaying that data (the window and
its controls) in the executable.  Updating the application updates the UI
for all user files, without requiring any conversion (those of us who cut
our teeth on HC remember writing complicated rutines to move data from old
stacks to new ones whenever we changed the UI).

But now we can raise the ante:  What if you want to support multiple
documents?   Certainly not an unreasonable request, as most applications do
it.  But how to do it in Rev?

One way is to make one substack in your exe serve as a template, using the
clone command to make a copy of that stack in memory in which to display the
contents of a user's data file.  You can store the path to the data file in
a custom prop of the cloned stack, binding the data to the UI object.  No
complicated housekeeping to keep trck of any nymber of open data files: just
get the uDataFile property (or whatever you decide to call it) of the

The old Mac API had placeholders in window and control records which served
a similar purpose, providing a way for developers to bind any arbitrary data
to specific objects.  Rev's custom properties provide the same benefits from
the grace and ease of a 4GL.

 Richard Gaskin 
 Fourth World Media Corporation
 Developer of WebMerge 2.2: Publish any database on any site
 Ambassador at
 Tel: 323-225-3717                       AIM: FourthWorldInc

More information about the use-livecode mailing list