×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Set Reprocess setting problem

Set Reprocess setting problem

Set Reprocess setting problem

(OP)
SET MULTILOCKS ON && Required for row or table buffering and allows multiple records to be locked using LOCK( ) or RLOCK( )

SET REFRESH TO 5,3
SET REPROCESS TO 5 SECONDS

Above are the setting for locking table BUT want to stop until or unless counter table Locked

For Locking using the following code

LOCAL isLocked , nKey

SELECT Counter

WAIT WINDOW 'Trying to Lock [ Computer No ] Table .... ' NOWAIT

do while ! m.isLocked
m.isLocked = flock('Counter')
enddo

RETURN m.isLocked

But not pausing the process until or unless file locked

RE: Set Reprocess setting problem

The parameters of REPROCESS are about automatic locks, not manual locks.

You're responsible how you want react to not getting manual locks yourself, that's not influenced by settings. There is no automatic EXIT of locking loops you do this way, how should there be, at what level should the exiting stop? There still is no general AI working in the background in a runtime.

Bye, Olaf.

RE: Set Reprocess setting problem

(OP)
What i understand

Set the Set Reprocess to Auto

2nd i have following code in OP Do while Loop

if m.nKey=27 && If Loop INTERRUPTED by Esc Key
exit
endif


RE: Set Reprocess setting problem

No

The delay is not relavant to LOCKS/RLOCKSat all, it is relevant to times you want to either USE a file exclusive that's open by someone else or UPDATE a file that's locked in the cahnged rrows by soemeone else and the delay just delays the ERROR 3 or 108 you get after VFP reprocessed the locking it needs for the USE or the UPDATE or TABLEUPDATE or whatever is the cause of the automatic locks is.

LOCK/RLOCK immediately give you a .F. or .T. and that never changes when you SET REPROCESS.

I said REPROCESS can't interfere with your code, it can't exit from a loop you do. And if you instread put an EXIT in your code, you immediately exit the code.

If you want to reproces RLOCKS, then simply do so with YOUR code.

Bye, Olaf.

RE: Set Reprocess setting problem

(OP)
Using the following code for table locking Please guide the best code for locking table trying to lock until or unless table locked

LOCAL isLocked , nKey

SELECT Gjno

WAIT WINDOW 'Trying to Lock [ Computer No ] Table .... ' NOWAIT

thisform.pp_cntlck = 1

DO WHILE ! m.isLocked

m.isLocked = FLOCK('Gjno')

thisform.pp_cntlck = thisform.pp_cntlck + 1

nKey=inkey()

if m.nKey=27 && If Loop INTERRUPTED by Esc Key
exit
endif

IF m.isLocked = .F. && If Flock Un-Successful then loop
LOOP
ENDIF

ENDDO

RETURN m.isLocked

RE: Set Reprocess setting problem

I tried. For FLOCK() SET REPROCESS works, Just don't do any loop.

CODE

Local llSuccess && intially .F.
SET REPROCESS TO 30 SECONDS
SELECT Table
llSuccess=FLOCK() 

I wouldn't try to lock for 30 seconds, though. Normally either you get a lock or you don't. There is almost no situation you get the lock after say half the timeout. You either get it immediately or the timeout happens. Unless you stage a situation where you yourself block the lock with another VFP session you end. But real life situations are rarely that way. Instead try to get exclusive use:

CODE

Local llSuccess && intially .F.
USE IN SELECT("Table") && close table
TRY
   USE Table In 0 EXCLUSIVE
   llSuccess = .T.
CATCH
   * Didn't work
ENDTRY 

The loop you did initially would never stop until you get the lock:

CODE

do while ! m.isLocked
m.isLocked = flock('Counter')
enddo 

Each loop iteration takes the time you specified in REPROCESS with SECONDS clause. But it runs endless, you could also SET REPROCESS TO -1 and just do FLOCK once. I'd spare users the time to wait for a timeout, though. It's a useless concept. When you don't have immediate success typically something is wrong and needs to be addressed anyway, eg any other session of the application hangs. Programming with manual locks is really unfortunate. Is your counter table used to create IDs?

Bye, Olaf.


RE: Set Reprocess setting problem

(OP)
Counter table (GjNo) providing Entry No for New Entries which is Unique and user has to save entry in Journal table

Earlier you said that Set Reprocess setting is not for FLOCK , LOCK

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close