Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you lock a record fast?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00758830
Message ID:
00758856
Views:
16
You can use binary search. Of a top of my head (not tested)
lnStart = 1
lnEnd = RECCOUNT()
lnMiddle = RECCOUNT()
lnRecnNo = 0
DO WHILE lnStart <= lnEnd
	lnMiddle = INT(lnStart + lnEnd ) /2)
	GOTO (lnMiddle)
	IF NOT RLOCK()
		lnStart = lnMiddle + 1
	ELSE
		lnEnd = lnMiddle - 1
		IF lnRecno > 0
			UNLOCK	RECORD lnRecno 
		ENDIF
		lnRecno = lnMiddle
	ENDIF
ENDDO	
>I’m trying to locate the next available unlocked record in a table.
>The table has about 150 records in it.
>
>When I use following code it may take 30 seconds if the 31 record is next available unlocked record and rLock() will return .T. but it is slow
>
>Sele the table
>scan
> IF rlock() = .t.
> ?rlock()
> endif
>endscan
>
>
>if I use this code it flies thru the isRlock function but will get .f. when it tries rLock()
>
>Sele the table
>scan
> IF isRlock() = .t.
> ?rlock()
> endif
>endscan
>
>What is the fasted way to do this?
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform