home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 12.3. Save all of the SET settings with SaveSets().
- Listing 12.4. Restore all of the SET settings with RestSets().
- Author: Greg Lief / Craig Yellick
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- // Stack used by both SaveSets() and RestSets().
- static setstack_ := {}
-
- function SaveSets()
- /*
- Save all SET variables onto the SET stack.
- */
- local i, settings_ := {}
-
- // Loop through all SETs to build a subarray.
- // (_SET_COUNT is found in STD.CH)
- for i := 1 to _SET_COUNT
- aadd(settings_, set(i))
- next i
-
- // Add the subarray to the SET stack.
- aadd(setstack_, settings_)
-
- return nil
-
-
- function RestSets()
- /*
- Restore all SET variables from the SET stack.
- */
-
- local i, settings_, ele := len(setstack_)
-
- // Avoid an empty array.
- if ele > 0
-
- // Load subarray from last elements of SET stack.
- settings_ = setstack_[ele]
-
- // Loop through subarray, assigning each SET as we go.
- // (_SET_COUNT is found in STD.CH)
- for i := 1 to _SET_COUNT
- set(i, settings_[i])
- next i
-
- // Truncate the SET stack.
- asize(setstack_, ele - 1)
- endif
-
- return nil
-
- // end of file CHP1203.PRG
-