Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Record locking in Fox for dos
Message
 
To
28/08/2002 03:51:26
Philip Jones
Cornwall County Council
Truro, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00694053
Message ID:
00694359
Views:
15
>What I've got is something like this
>
>SET REPROCESS TO AUTOMATIC
>SELECT NextRef
>=FLOCK()
>Read the number
>increment the number
>write it back
>unlock
>
>Am I right in thinking that with reprocess set to automatic the flock() function will attempt over and over again to lock the file until a successful lock is placed? In which case it the code below the call to flock() will never be executed unless the file is locked.

Generally, yes. But now be careful;
Once the Esc button is in effect, and the user can press escape, the FLOCK() attempts will stop. And then the code continues ...

Look at this help snippet too :

Note If FLOCK( ) fails to lock a table, it returns false (.F.) and does not generate an error. As a result, you can’t use FLOCK( ) to trigger an ON ERROR routine.

This would happen at Esc (when allowed), and you really should be coding like this :
SELECT NextRef
IF NOT FLOCK()
  *** some message ***
  RETURN 'Failed'    && Give possibility to try again or abort the process.
ELSE
  Read the number
  increment the number
  write it back
  unlock
  RETURN 'Succeeded'
ENDIF
HTH,
Peter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform