home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / SCHINKEL.ZIP / PPSCR.PRG < prev    next >
Encoding:
Text File  |  1990-05-17  |  2.1 KB  |  58 lines

  1. /* PPSCR.PRG - Streen Stack Functions for use with Clipper 5.0
  2.  
  3.    This file contains two functions PUSHSCR() and POPSCR() that implement
  4.    a screen stack.  As implemented, they open a file using FOPEN() and leave
  5.    it open (thus using a file handle).  The screen file name is determined by
  6.    FUNIQUE(). POPSCR() will delete the file when it no longer contains any
  7.    screens (nScrPtr==0).
  8.  
  9.    SWITCHES: /n /m /w
  10.  
  11.    REQUIRES: FUNIQUE(), TEMPDIR()
  12.  
  13.    Copyright (c) 1990; The DSW Group, Ltd.
  14. */
  15.  
  16. #include "lang_enh.ch"  // Miscellaneous Language Enhancements
  17. #include "llfio.ch"     // Low Level File I/O
  18.  
  19. STATIC nScrHand:=NIL,;  && Contains file handle for screen stack file.
  20.        nScrPtr:= 0,;    && Points to next screen "record" in stack file.
  21.        cScrFile:= ""    && Contains path&name of screen file
  22.  
  23. //..........................................................................
  24. PROC PushScr(nTR,nLC,nBR,nRC) // Optional parameters
  25.    DEFAULT nTR TO 0, nLC TO 0, nBR TO 24, nRC TO 79
  26.    IF (nScrHand==NIL)
  27.       nScrHand:= FOpen(cScrFile:= FUnique(TempDir(),NORMAL_ATTR),RW_EXCLUSIVE)
  28.    ENDIF
  29.    FSeek(nScrHand, 4096 * (nScrPtr++), FROM_BOF)
  30.    FWrite(nScrHand,Chr(nTR)+Chr(nLC)+Chr(nBR)+Chr(nRC)+;
  31.                    SaveScreen(nTR,nLC,nBR,nRC), 4096)
  32. RETURN
  33.  
  34. //..........................................................................
  35. #define BufTR()  Asc(SubStr(cScrBuffer,1,1))
  36. #define BufLC()  Asc(SubStr(cScrBuffer,2,1))
  37. #define BufBR()  Asc(SubStr(cScrBuffer,3,1))
  38. #define BufRC()  Asc(SubStr(cScrBuffer,4,1))
  39. #define BufScr() SubStr(cScrBuffer,5)
  40.  
  41. PROC PopScr(lRestore)
  42. LOCAL cScrBuffer:= SPACE(4096)
  43.    DEFAULT lRestore TO YES
  44.    RETURN IF (nScrPtr<=0)
  45.    nScrPtr--
  46.    IF (lRestore)
  47.       FSeek(nScrHand, (4096*nScrPtr), FROM_BOF)
  48.       FRead(nScrHand, @cScrBuffer, 4096)
  49.       RestScreen(BufTR(),BufLC(),BufBR(),BufRC(),BufScr())
  50.    ENDIF
  51.    IF (nScrPtr==0)
  52.       FClose(nScrHand);  FErase(cScrFile);  nScrHand:= NIL
  53.    ENDIF
  54. RETURN
  55.  
  56. //..........................................................................
  57. // EOF: PPSCR.PRG
  58.