home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 12.1. Save the screen environment with SaveEnv().
- Listing 12.2. Restore previous environment with RestEnv().
- 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 SaveEnv() and RestEnv().
- static envstack_ := {}
-
- // Manifest constants used by RestEnv().
- #define ROW 1
- #define COLUMN 2
- #define CURSOR 3
- #define COLOR 4
- #define SCREEN 5
-
- function SaveEnv()
- /*
- Save current cursor row/column/size, color, and screen.
- */
-
- aadd(envstack_, { row(), col(), ;
- setcursor(), ;
- setcolor(), ;
- savescreen(0, 0, maxrow(), maxcol()) } )
- return nil
-
- function RestEnv()
- /*
- Restore cursor row/column/size, color, and screen.
- */
- local ele := len(envstack_)
-
- // Avoid an empty array,
- // which would cause an array access error.
- if ele > 0
-
- // Restore row/column position.
- setpos(envstack_[ele, ROW], envstack_[ele, COLUMN])
-
- // Restore cursor state.
- setcursor(envstack_[ele, CURSOR])
-
- // Restore color.
- setcolor(envstack_[ele, COLOR])
-
- // Restore screen.
- restscreen(0, 0, maxrow(), maxcol(), envstack_[ele, SCREEN])
-
- // Truncate array by lopping off last element.
- asize(envstack_, ele - 1)
- endif
-
- return nil
-
- // end of file CHP1201.PRG
-