home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP26.EXE / CHP2604.PRG < prev    next >
Encoding:
Text File  |  1991-06-12  |  957 b   |  37 lines

  1. /*
  2.    Listing 26.4 Stack-Based Functions to Save/Restore GETs
  3.    Author: Greg Lief
  4.    Excerpted from Grumpfish Library
  5.    Copyright (c) 1988-91 Greg Lief
  6. */
  7.  
  8. //───── NOTE: must compile with the /N option!
  9.  
  10. static getstack_ := {}
  11.  
  12. memvar getlist
  13.  
  14. // GFSaveGets(): save current gets
  15. function GFSaveGets()
  16. aadd(getstack_, getlist)
  17. getlist := {}                          // clear out current gets
  18. return len(getstack_)
  19.  
  20.  
  21. // GFRestGets(): restore last-saved gets
  22. function GFRestGets(ele)
  23. //───── use LIFO (last item in array) if no parameter was passed
  24. ele := if(ele == NIL, len(getstack_), ele)
  25. //───── preclude empty array */
  26. if len(getstack_) > 0
  27.    //───── pull GETs from last element in array
  28.    getlist := getstack_[ele]
  29.    //───── truncate length of array only if using LIFO
  30.    if ele == len(getstack_) .and. pcount() = 0
  31.       asize(getstack_, len(getstack_) - 1)
  32.    endif
  33. endif
  34. return nil
  35.  
  36. // end of file CHP2604.PRG
  37.