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

  1. /*
  2.  * File......: NETUSE.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_NETUSE()
  24.  *  $CATEGORY$
  25.  *      Network
  26.  *  $ONELINER$
  27.  *      Attempt to USE a dbf with optional retry
  28.  *  $SYNTAX$
  29.  *      GT_NetUse( cDatabase, lOpenMode, nSeconds )
  30.  *  $ARGUMENTS$
  31.  *      cDatabase - Table to open
  32.  *      lOpenMode - Mode to open
  33.  *      nSeconds  - Number of retries allowed - 0 for infinite number
  34.  *  $RETURNS$
  35.  *      .T. if successful, .F. otherwise
  36.  *  $DESCRIPTION$
  37.  *      Attempts to open the table.  If it fails, waits a second and retries.
  38.  *      After nSeconds retries it aborts.
  39.  *  $EXAMPLES$
  40.  *
  41.  *  $SEEALSO$
  42.  *
  43.  *  $INCLUDE$
  44.  *
  45.  *  $END$
  46.  */
  47.  
  48. *
  49. FUNCTION GT_NetUse( cDatabase, lOpenMode, nSeconds )
  50.  
  51. /*****************************************************************************
  52.  Purpose - Attempt to USE a dbf with optional retry
  53.  Returns - .T. if successful, .F. otherwise
  54.  Author  - Martin Colloby
  55.  Created - 20/05/92
  56. ******************************************************************************
  57.  Parameters - cDatabase - Table to open
  58.               lOpenMode - Mode to open
  59.               nSeconds  - Number of retries allowed
  60.  Privates   - None
  61.  Locals     - lForever - If .T., loop forever
  62.  Externals  - None
  63. *****************************************************************************/
  64.  
  65. LOCAL lForever := (nSeconds == 0)
  66.  
  67. DO WHILE (lForever .OR. nSeconds > 0)
  68.     IF lOpenMode
  69.         USE (cDatabase) EXCLUSIVE NEW
  70.     ELSE
  71.         * Shared mode
  72.         USE (cDatabase) SHARED NEW
  73.     ENDIF
  74.  
  75.     * USE succeeds
  76.     IF .NOT. NETERR()
  77.         RETURN (.T.)
  78.     ENDIF
  79.  
  80.     * Wait 1 second
  81.     INKEY(1)
  82.     nSeconds := nSeconds - 1
  83.  
  84. ENDDO
  85.  
  86. * USE fails
  87. RETURN (.F.)
  88. *
  89.