Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>net_use() attempt to open a database file locks.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Net_use()      Attempt to open a database file             Locks.prg


Syntax:        Net_use(<expC>, <expL>, <seconds>)

Arguments:     <expC> is the name of the database file to open.

               <expL> is the mode of the open.  True (.T.) is
               exclusive and false (.F.) is shared.

               <seconds> is the number of seconds to continue the
               attempt to open the specified file.  A value of zero
               means to continue indefinitely.

Returns:       Net_use() returns true (.T.) if the database file was
               opened; otherwise it returns false (.F.).


----------------------------------- Example --------------------------------

   open_mode   = .T.       && Open exclusive.
   wait_secs   = 5         && Attempt to open for five seconds.

   IF Net_use("Accounts", open_mode, wait_secs)
      SET INDEX TO Name
   ELSE
      ? "Account file not available"
   ENDIF


--------------------------------- Source Code ------------------------------

   FUNCTION NET_USE
   PARAMETERS file, ex_use, wait
   PRIVATE forever

   forever = (wait = 0)
   DO WHILE (forever .OR. wait > 0)

      IF ex_use                    && exclusive
         USE &file EXCLUSIVE
      ELSE
         USE &file                 && shared
      ENDIF

      IF .NOT. NETERR()            && USE succeeds
         RETURN (.T.)
      ENDIF

      INKEY(1)                     && wait 1 second
      wait = wait - 1
   ENDDO
   RETURN (.F.)                    && USE fails


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson