home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 12.5. Save the current set of GETs with SaveGets().
- Listing 12.6. Restore previously saved GETs with RestGets().
- 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 SaveGets() and RestGets()
- static getstack_ := {}
- memvar getlist // to squelch compiler warnings
-
- function SaveGets()
- /*
- Save current GETs and clear 'em out.
- Returns the stack position where the GETs are stored.
- */
-
- // Add current GETs to stack.
- aadd(getstack_, getlist)
-
- // Clear the current GETs.
- getlist := {}
-
- return len(getstack_)
-
-
-
- function RestGets(ele)
- /*
- Restore GETs from stack.
-
- ele Element number to restore, optional.
- */
-
- // Use LIFO (last item in array) if no parameter was passed.
- ele = if(ele == NIL, len(getstack_), ele)
-
- // Avoid an empty array
- if len(getstack_) > 0 .and. ele <= len(getstack_)
-
- // Assign previously saved GETs to current
- getlist := getstack_[ele]
-
- // Truncate length of array only if using LIFO
- // i.e., no param passed.
- if ele == len(getstack_) .and. pcount() = 0
- asize(getstack_, len(getstack_) - 1)
- endif
- endif
-
- return nil
-
-
- // end of file CHP1205.PRG
-