contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
declaration/definition   save    
Sample Code   Related Syntax   Related Concepts  

Syntax

  save shelf-type? shelf-name


Purpose

A declaration that can be intermixed with local variable declarations of a local scope. The save declaration can only be applied to global shelves. It causes a copy to be made of the specified shelf. For the duration of the local scope, every time the global shelf is referenced by name, it is the copy that is used. (This includes references from inside nested rules, from function calls, and from other rules.) When the local scope completes, the copy is destroyed and the saved shelf becomes the accessible one.

Essentially, save guarantees that a global shelf will have the same contents at the end of a local scope as it did at the beginning.

It is an error to save the same shelf in both domains (the output processor and the input processor) at the same time. This feature prevents getting saves that are not properly nested with respect to each other. It also ensures that shelves will always be "unsaved" in the opposite order from which they were saved.

Because save is a declaration, it may not have conditions.

When save is applied to a stream shelf, every item on that shelf must be either unattached or closed and attached to a buffer.

The shelf-type is an optional herald indicating the shelf type.

The following is an example of the effect of save on current item selection. This code outputs "20" and then "30":

  local counter my-shelf size 3

     set my-shelf @ 1 to 10
     set my-shelf @ 2 to 20
     set my-shelf @ 3 to 30
     using my-shelf @ 2
     do
        output "%d(my-shelf)%n"
        do
           save my-shelf
           output "%d(my-shelf)%n"
        done
     done

Sample Code  
   Binding shelf instances with "using"
 
Related Syntax
   save-clear
   save groups
 
Related Concepts
   Functions: applying "save" to arguments
   Global variables: saving values in local scopes
   Shelves: save declarations mixed with local declarations
   Shelves: saving contents
 
----

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:15 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.