Re: harbour lock function
Posted: Fri Oct 15, 2010 7:55 am
Hi l3whmg,
just for curiosity:
you tried to test DBRLockList() against the record to be locked?
If the record already locked in the process A is present in the list you could obtain the expected behaviour using:
I not tested, however.
Very interesting question, as I also have same problem to protect the edit of same record in the same application.
Best regards.
Maurizio
just for curiosity:
you tried to test DBRLockList() against the record to be locked?
If the record already locked in the process A is present in the list you could obtain the expected behaviour using:
Code: Select all
/***************************************************************
* try to lock a record
***************************************************************/
FUNCTION RecLock(cAliasName, nRecNum)
LOCAL lLock := .F.
LOCAL cAlias := IIF(VALTYPE(cAliasName)=="C", ALLTRIM(cAliasName), "")
LOCAL nSeconds := NET_SECS * 2
LOCAL nCurArea := SELECT(), nArea := 0
LOCAL nNumRec := 0
nArea := IIF(LEN(cAlias)>0, SELECT(cAlias), SELECT())
IF nArea<>0
DBSELECTAREA(nArea)
IF VALTYPE(nRecNum)=="N" .AND. nRecNum>0 .AND. nRecNum<=LASTREC()
nNumRec := nRecNum
ELSE
nNumrec := RECNO()
ENDIF
if AScan( DBRLockList(), { |e| e == nNumrec } ) == 0 // <<<------
IF DBRLOCK(nNumRec)
lLock := .T.
ELSE
WAIT WINDOW "Record Lock Processing..." NOWAIT
WHILE nSeconds>0
DO EVENTS
IF DBRLOCK(nNumRec)
lLock := .T.
EXIT
ELSE
* waiting
INKEY(NET_WAIT)
nSeconds -= NET_WAIT
ENDIF
END
WAIT CLEAR
ENDIF
ENDIF
endif // <<------
DBSELECTAREA(nCurArea)
RETURN lLockVery interesting question, as I also have same problem to protect the edit of same record in the same application.
Best regards.
Maurizio