home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP12.EXE / CHP1203.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  1.3 KB  |  59 lines

  1. /*
  2.    Listing 12.3. Save all of the SET settings with SaveSets().
  3.    Listing 12.4. Restore all of the SET settings with RestSets().
  4.    Author: Greg Lief / Craig Yellick
  5.    Excerpted from "Clipper 5: A Developer's Guide"
  6.    Copyright (c) 1991 M&T Books
  7.                       501 Galveston Drive
  8.                       Redwood City, CA 94063-4728
  9.                       (415) 366-3600
  10. */
  11.  
  12. //  Stack used by both SaveSets() and RestSets().
  13. static setstack_ := {}
  14.  
  15. function SaveSets()
  16. /*
  17.    Save all SET variables onto the SET stack.
  18. */
  19. local i, settings_ := {}
  20.  
  21.   //  Loop through all SETs to build a subarray.
  22.   //  (_SET_COUNT is found in STD.CH)
  23.   for i := 1 to _SET_COUNT
  24.     aadd(settings_, set(i))
  25.   next i
  26.  
  27.   //  Add the subarray to the SET stack.
  28.   aadd(setstack_, settings_)
  29.  
  30. return nil
  31.  
  32.  
  33. function RestSets()
  34. /*
  35.    Restore all SET variables from the SET stack.
  36. */
  37.  
  38. local i, settings_, ele := len(setstack_)
  39.  
  40.   //  Avoid an empty array.
  41.   if ele > 0
  42.  
  43.     //  Load subarray from last elements of SET stack.
  44.     settings_ = setstack_[ele]
  45.  
  46.     //  Loop through subarray, assigning each SET as we go.
  47.     //  (_SET_COUNT is found in STD.CH)
  48.     for i := 1 to _SET_COUNT
  49.       set(i, settings_[i])
  50.     next i
  51.  
  52.     //  Truncate the SET stack.
  53.     asize(setstack_, ele - 1)
  54.   endif
  55.  
  56. return nil
  57.  
  58. // end of file CHP1203.PRG
  59.