home *** CD-ROM | disk | FTP | other *** search
- /* PPSCR.PRG - Streen Stack Functions for use with Clipper 5.0
-
- This file contains two functions PUSHSCR() and POPSCR() that implement
- a screen stack. As implemented, they open a file using FOPEN() and leave
- it open (thus using a file handle). The screen file name is determined by
- FUNIQUE(). POPSCR() will delete the file when it no longer contains any
- screens (nScrPtr==0).
-
- SWITCHES: /n /m /w
-
- REQUIRES: FUNIQUE(), TEMPDIR()
-
- Copyright (c) 1990; The DSW Group, Ltd.
- */
-
- #include "lang_enh.ch" // Miscellaneous Language Enhancements
- #include "llfio.ch" // Low Level File I/O
-
- STATIC nScrHand:=NIL,; && Contains file handle for screen stack file.
- nScrPtr:= 0,; && Points to next screen "record" in stack file.
- cScrFile:= "" && Contains path&name of screen file
-
- //..........................................................................
- PROC PushScr(nTR,nLC,nBR,nRC) // Optional parameters
- DEFAULT nTR TO 0, nLC TO 0, nBR TO 24, nRC TO 79
- IF (nScrHand==NIL)
- nScrHand:= FOpen(cScrFile:= FUnique(TempDir(),NORMAL_ATTR),RW_EXCLUSIVE)
- ENDIF
- FSeek(nScrHand, 4096 * (nScrPtr++), FROM_BOF)
- FWrite(nScrHand,Chr(nTR)+Chr(nLC)+Chr(nBR)+Chr(nRC)+;
- SaveScreen(nTR,nLC,nBR,nRC), 4096)
- RETURN
-
- //..........................................................................
- #define BufTR() Asc(SubStr(cScrBuffer,1,1))
- #define BufLC() Asc(SubStr(cScrBuffer,2,1))
- #define BufBR() Asc(SubStr(cScrBuffer,3,1))
- #define BufRC() Asc(SubStr(cScrBuffer,4,1))
- #define BufScr() SubStr(cScrBuffer,5)
-
- PROC PopScr(lRestore)
- LOCAL cScrBuffer:= SPACE(4096)
- DEFAULT lRestore TO YES
- RETURN IF (nScrPtr<=0)
- nScrPtr--
- IF (lRestore)
- FSeek(nScrHand, (4096*nScrPtr), FROM_BOF)
- FRead(nScrHand, @cScrBuffer, 4096)
- RestScreen(BufTR(),BufLC(),BufBR(),BufRC(),BufScr())
- ENDIF
- IF (nScrPtr==0)
- FClose(nScrHand); FErase(cScrFile); nScrHand:= NIL
- ENDIF
- RETURN
-
- //..........................................................................
- // EOF: PPSCR.PRG