[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+-----------+##############################################################
#+-| A_RLOCK() |-----------------------------------+##########################
#| +-----------+ Locks a record in specific alias. |##########################
#+-------------------------------------------------+##########################
##############################################################################
##############################################################################
#+--| Summary |------------------+############################################
#| #INCLUDE database.hdr |############################################
#+-------------------------------+############################################
##############################################################################
##############################################################################
#+--| Syntax |--------------------------------+###############################
#| FUNCTION LOGICAL a_rlock PROTOTYPE |###############################
#| PARAMETERS ALIAS aliasname |###############################
#+--------------------------------------------+###############################
##############################################################################
##############################################################################
######+---| Description |----------------------------------------------+######
######| The a_rlock() function attempts to lock the current record in |######
######| the specified aliasname. If the lock is successful, a_rlock() |######
######| returns TRUE. Any locks, record or file currently assigned to |######
######| aliasname are released and, if a_rlock() is unsuccessful, the |######
######| locks are not restored. |######
######+----------------------------------------------------------------+######
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| * Lock a record prior to a GET command. Be sure |#########
#########| * the time between the GET and the READ is |#########
#########| * minimal, because another process could be |#########
#########| * waiting for the record. |#########
#########| |#########
#########| IF .NOT. a_rlock( aliasname ) |#########
#########| ? "Unable to access record..." |#########
#########| ENDIF |#########
#########| @ x,y SAY "Name: " GET aliasname->name |#########
#########| READ |#########
#########| UNLOCK |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * A "wait for a record" function. Waits for N |#########
#########| * seconds for a record. |#########
#########| |#########
#########| FUNCTION LOGICAL wait_for_record |#########
#########| PARAMETERS VALUE INT seconds, ALIAS a |#########
#########| VARDEF |#########
#########| LONG ts |#########
#########| ENDDEF |#########
#########| |#########
#########| ts = time_seconds() + seconds |#########
#########| REPEAT |#########
#########| IF a_rlock( a ) |#########
#########| RETURN .T. |#########
#########| ENDIF |#########
#########| UNTIL time_seconds() > ts |#########
#########| RETURN .F. |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
a_flock()
flock()
OPEN
rlock()
UNLOCK
USE
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson