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

  1. /*
  2.    Listing 12.5. Save the current set of GETs with SaveGets().
  3.    Listing 12.6. Restore previously saved GETs with RestGets().
  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 SaveGets() and RestGets()
  13. static getstack_ := {}
  14. memvar getlist             // to squelch compiler warnings
  15.  
  16. function SaveGets()
  17. /*
  18.    Save current GETs and clear 'em out.
  19.    Returns the stack position where the GETs are stored.
  20. */
  21.  
  22.   //  Add current GETs to stack.
  23.   aadd(getstack_, getlist)
  24.  
  25.   //  Clear the current GETs.
  26.   getlist := {}
  27.  
  28. return len(getstack_)
  29.  
  30.  
  31.  
  32. function RestGets(ele)
  33. /*
  34.    Restore GETs from stack.
  35.  
  36.    ele  Element number to restore, optional.
  37. */
  38.  
  39.   //  Use LIFO (last item in array) if no parameter was passed.
  40.   ele = if(ele == NIL, len(getstack_), ele)
  41.  
  42.   //  Avoid an empty array
  43.   if len(getstack_) > 0 .and. ele <= len(getstack_)
  44.  
  45.      //  Assign previously saved GETs to current
  46.      getlist := getstack_[ele]
  47.  
  48.      //  Truncate length of array only if using LIFO
  49.      //  i.e., no param passed.
  50.      if ele == len(getstack_) .and. pcount() = 0
  51.         asize(getstack_, len(getstack_) - 1)
  52.      endif
  53.   endif
  54.  
  55. return nil
  56.  
  57.  
  58. // end of file CHP1205.PRG
  59.