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

  1. /*
  2.     File......: GT_Append.prg
  3.     Author....: Martin Bryant
  4.     BBS.......: The Dark Knight Returns
  5.     Net/Node..: 050/069
  6.     User Name.: Martin Bryant
  7.     Date......: 11/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 11/02/93
  17.     PD Revision.
  18. */
  19.  
  20. /*  $DOC$
  21.  *  $FUNCNAME$
  22.  *      GT_APPEND()
  23.  *  $CATEGORY$
  24.  *      General
  25.  *  $ONELINER$
  26.  *      Append a blank record to a DBF file. It is also locked.
  27.  *  $SYNTAX$
  28.  *      GT_Append([<nTimeout>],[<nPause>]) -> lSuccess
  29.  *  $ARGUMENTS$
  30.  *  $RETURNS$
  31.  *      lSuccess
  32.  *  $DESCRIPTION$
  33.  *      Append a blank record to a DBF file. It is also locked.
  34.  *  $EXAMPLES$
  35.  *      // Add new, default waiting values
  36.  *      IF .NOT. GT_Append()
  37.  *          ? 'Error'
  38.  *      ENDIF
  39.  *  $SEEALSO$
  40.  *
  41.  *  $INCLUDE$
  42.  *
  43.  *  $END$
  44.  */
  45.  
  46. */
  47. #include "GT_LIB.ch"
  48.  
  49. #define HEIGHT  06
  50. #define WIDTH   16
  51.  
  52. FUNCTION GT_Append(nSeconds,nPause)
  53.  
  54. LOCAL cScreen := ''
  55. LOCAL lMessage := .F.
  56. LOCAL lSuccess := .F.
  57. LOCAL nBottom := INT((MAXROW() + HEIGHT)/2)
  58. LOCAL nKey := 0
  59. LOCAL nLeft := INT((MAXCOL() - WIDTH)/2)
  60. LOCAL nRight := nLeft - WIDTH
  61. LOCAL nTop := nBottom - HEIGHT
  62.  
  63. Default nSeconds to 120
  64. Default nPause to 0.5
  65.  
  66. DO WHILE nSeconds > 0 .AND. (.NOT. lSuccess) .AND. ;
  67.     (nKey != K_ESC)
  68.  
  69.     // Attempt append
  70.     DBAPPEND()
  71.     lSuccess := .NOT. NetErr()
  72.  
  73.     IF .NOT. lSuccess
  74.  
  75.         // Message ?
  76.         IF .NOT. lMessage
  77.  
  78.             // Save
  79.             cScreen := SAVESCREEN(nTop,nLeft,nBottom,nRight)
  80.  
  81.             // Display
  82.             GT_Window(nTop,nLeft,nBottom,nRight,BOX_SS, ;
  83.                 NIL,'Appending ....',.T.)
  84.  
  85.             // Position for message
  86.             @ nTop+02, nLeft+02 SAY 'Timeout:'
  87.             @ nTop+04, nLeft+02 SAY PADC('Esc∙Exit',WIDTH-03)
  88.  
  89.             lMessage := .T.
  90.  
  91.         ENDIF
  92.  
  93.         @ nTop+02, nLeft+09 SAY PADR(INT(nSeconds),3)
  94.  
  95.         // Wait
  96.         nKey := INKEY(nPause)
  97.         nSeconds -= nPause
  98.  
  99.     ENDIF
  100.  
  101. ENDDO
  102.  
  103. IF lMessage
  104.     RESTSCREEN(nTop,nLeft,nBottom,nRight,cScreen)
  105. ENDIF
  106.  
  107. /*
  108.     End GT_Append()
  109. */
  110. RETURN(lSuccess)
  111.  
  112.