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

  1. /*
  2.  * File......: ADDREC.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_ADDREC()
  24.  *  $CATEGORY$
  25.  *      Network
  26.  *  $ONELINER$
  27.  *      Attempt to APPEND BLANK with optional retry
  28.  *  $SYNTAX$
  29.  *      GT_AddRec( nSeconds )
  30.  *  $ARGUMENTS$
  31.  *      nSeconds - Number of retry attempts (one per second)
  32.  *  $RETURNS$
  33.  *      .T. is successful, .F. otherwise
  34.  *  $DESCRIPTION$
  35.  *      Attempts to perform an APPEND BLANK to a network table.  If successful,
  36.  *      returns .F., with the blank record selected.  If unsuccessful, waits
  37.  *      for one second and tries again until nSeconds attempts have been made.
  38.  *
  39.  *      If nSeconds is 0, the routine will loop indefinately.
  40.  *
  41.  *      The table to be added to should be SELECTed before calling.
  42.  *  $EXAMPLES$
  43.  *      Add a record, aborting if not successful at the first attempt :
  44.  *
  45.  *          GT_AddRec( 1 )
  46.  *  $SEEALSO$
  47.  *
  48.  *  $INCLUDE$
  49.  *
  50.  *  $END$
  51.  */
  52.  
  53. FUNCTION GT_AddRec( nSeconds )
  54.  
  55. /*****************************************************************************
  56.  Purpose - Attempt to APPEND BLANK with optional retry
  57.  Returns - .T. if successful
  58.  Author  - Martin Colloby
  59.  Created - 20/05/92
  60. ******************************************************************************
  61.  Parameters - nSeconds - Number of retries
  62.  Privates   - None
  63.  Locals     - lForever - If .T., loop forever
  64.  Externals  - None
  65. *****************************************************************************/
  66.  
  67. LOCAL lForever := (nSeconds == 0)
  68.  
  69. APPEND BLANK
  70.  
  71. IF .NOT. NETERR()
  72.     RETURN (.T.)
  73. ENDIF
  74.  
  75. DO WHILE (lForever .OR. nSeconds > 0)
  76.     APPEND BLANK
  77.     IF .NOT. NETERR()
  78.         RETURN .T.
  79.     ENDIF
  80.  
  81.     * Wait 1/2 second
  82.     INKEY(.5)
  83.     nSeconds := nSeconds - .5
  84.  
  85. ENDDO
  86.  
  87. * Not locked
  88. RETURN (.F.)
  89. *
  90.