home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a067 / 1.img / GRUMP501.EXE / SETS.PRG < prev    next >
Encoding:
Text File  |  1991-05-07  |  1.5 KB  |  58 lines

  1. /*
  2.    SETS.PRG
  3.    Functions to save and restore all SET variables
  4.    Clipper 5.x version
  5.    Compile instructions: clipper sets /n/w/a
  6.    Copyright (c) 1990 Greg Lief - All Rights Reserved
  7. */
  8.  
  9. //───── begin global declarations
  10.  
  11. #include "grump.ch"
  12.  
  13. static setstack_ := {}       // will serve as SET stack
  14.  
  15. //───── end global declarations
  16.  
  17. /*
  18.     Function: GFSaveSets()
  19.     Purpose:  Save all SET variables onto the SET stack
  20. */
  21. function GFSaveSets
  22. local xx, settings_ := {}
  23. for xx := 1 to _SET_COUNT            /* see STD.CH for this */
  24.    aadd(settings_, set(xx))
  25. next
  26. aadd(setstack_, settings_)
  27. return len(setstack_)
  28.  
  29. * end of function GFSaveSets()
  30. *--------------------------------------------------------------------*
  31.  
  32.  
  33. /*
  34.     Function: GFRestSets()
  35.     Purpose:  Restore all SET variables from the SET stack
  36. */
  37. function GFRestSets(ele)
  38. local xx, settings_
  39. /* use LIFO (last item in array) if no parameter was passed */
  40. default ele to len(setstack_)
  41. /* preclude empty array! */
  42. if len(setstack_) > 0 .and. ele <= len(setstack_)
  43.    settings_ := setstack_[ele]
  44.    for xx := 1 to _SET_COUNT            /* see STD.CH for this */
  45.       set(xx, settings_[xx])
  46.    next
  47.    /* truncate length of array only if using LIFO, i.e., no param passed */
  48.    if ele == len(setstack_) .and. pcount() = 0
  49.       truncate(setstack_)
  50.    endif
  51. endif
  52. return nil
  53.  
  54. * end of function GFRestSets()
  55. *--------------------------------------------------------------------*
  56.  
  57. * eof sets.prg
  58.