home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / gt_memsa.prg < prev    next >
Text File  |  1993-10-14  |  3KB  |  120 lines

  1. /*
  2.     File......: GT_MemSave.prg
  3.     Author....: Martin Bryant
  4.     BBS.......: The Dark Knight Returns
  5.     Net/Node..: 050/069
  6.     User Name.: Martin Bryant
  7.     Date......: 04/02/93
  8.     Revision..: 1.0
  9.  
  10.     This is an original work by Martin Bryant and is placed
  11.     in the public domain.
  12.  
  13.     Modification history:
  14.     ---------------------
  15.  
  16.     Rev 1.0 04/02/93
  17.     PD Revision.
  18. */
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *      GT_MEMSAVE()
  23.  *  $CATEGORY$
  24.  *      File I/O
  25.  *  $ONELINER$
  26.  *      To save variables to a .mem file
  27.  *  $SYNTAX$
  28.  *      GT_MemSave(<cFile>,<cFilter>,[<nSeconds>],<nPause>]) => lSuccess
  29.  *  $ARGUMENTS$
  30.  *      <cFile> is the name, including path and extention,
  31.  *      of the file to save to.
  32.  *
  33.  *      <cFilter> is the specification of the variables to
  34.  *      save.
  35.  *
  36.  *      <nSeconds> is the time to wait.
  37.  *
  38.  *      <nPause> is the time interval between attempts.
  39.  *  $RETURNS$
  40.  *      .T. / .F.
  41.  *  $DESCRIPTION$
  42.  *      To save variables to a .mem file
  43.  *  $EXAMPLES$
  44.  *      IF .NOT. GT_MemSave('System.mem','p*')
  45.  *          ? 'Error'
  46.  *      ENDIF
  47.  *  $SEEALSO$
  48.  *
  49.  *  $INCLUDE$
  50.  *
  51.  *  $END$
  52.  */
  53.  
  54. #include "GT_LIB.ch"
  55.  
  56. #define HEIGHT  06
  57. #define WIDTH   16
  58.  
  59. FUNCTION GT_MemSave(cFile,cFilter,nSeconds,nPause)
  60.  
  61. Local cScreen := ''
  62. LOCAL nBottom := INT((MAXROW() + HEIGHT)/2)
  63. LOCAL nKey := 0
  64. LOCAL nLeft := INT((MAXCOL() - WIDTH)/2)
  65. LOCAL nRight := nLeft - WIDTH
  66. LOCAL nTop := nBottom - HEIGHT
  67. Local lMessage := .F.
  68. Local lSuccess := .F.
  69.  
  70. Default cFile to 'System.mem'
  71. Default cFilter to '*'
  72. Default nSeconds to 120
  73. Default nPause to 0.5
  74.  
  75. DO WHILE (.NOT. lSuccess) .AND. (nSeconds > 0) .AND. ;
  76.     (nKey != K_ESC)
  77.  
  78.     // Save ?
  79.     SAVE ALL LIKE (cFilter) TO (cFile)
  80.     lSuccess := (FERROR() == 0)
  81.  
  82.     IF .NOT. lSuccess
  83.  
  84.         // Wait and retry
  85.         IF .NOT. lMessage
  86.  
  87.             // Save
  88.             cScreen := SAVESCREEN(nTop,nLeft,nBottom,nRight)
  89.  
  90.             // Display
  91.             GT_Window(nTop,nLeft,nBottom,nRight,BOX_SS, ;
  92.                 NIL,'Saving ....',.T.)
  93.  
  94.             // Position for message
  95.             @ nTop+02, nLeft+02 SAY 'Timeout:'
  96.             @ nTop+04, nLeft+02 SAY ;
  97.                 PADC('Esc∙Exit',WIDTH-03)
  98.  
  99.             lMessage := .T.
  100.  
  101.         ENDIF
  102.  
  103.         @ nTop+02, nLeft+09 SAY PADR(INT(nSeconds),3)
  104.         nKey := INKEY(nPause)
  105.         nSeconds -= nPause
  106.  
  107.     ENDIF
  108.  
  109. ENDDO
  110.  
  111. IF lMessage
  112.     RESTSCREEN(nTop,nLeft,nBottom,nRight,cScreen)
  113. ENDIF
  114.  
  115. /*
  116.     End of GT_MemSave()
  117. */
  118. RETURN(lSuccess)
  119.  
  120.