PRB: Values Not Stored Correctly in a Multiuser EnvironmentLast reviewed: April 29, 1996Article ID: Q98699 |
The information in this article applies to:
SYMPTOMSIn a multiuser environment, programs that assign values to memory variables from database fields may not have access to the most recent values of those database fields.
CAUSETo reproduce this problem, create a database with a numeric field, named FIELD1, and one record. Assign an initial value of 1 to FIELD1. Start the following program on one workstation:
SET EXCLUSIVE OFF SET TALK OFF USE <database> DO WHILE .T. m.memvar = field1 WAIT WINDOW NOWAIT "Current value of FIELD1 is: " + ; LTRIM(STR(m.memvar)) ENDDOStart the following program on a second workstation:
SET EXCLUSIVE OFF SET TALK OFF USE <database> FOR i = 1 TO 2000 REPLACE field1 WITH i WAIT WINDOW NOWAIT "Current value of FIELD1 is: " + ; LTRIM(STR(i)) ENDFORChanges in the value of FIELD1 should be reflected in the first workstation's display; however, the displayed value of FIELD1 never changes. NOTE: Unless an RLOCK() function is issued, FoxPro does not re-read the current record.
RESOLUTIONFor memory variables to be assigned the most current information from a database record, an RLOCK() function should be issued before performing the assignment. In the code example above, the first workstation's code should be modified to read:
SET EXCLUSIVE OFF SET TALK OFF SET REPROCESS TO <an appropriate interval> USE <database> DO WHILE .T. IF RLOCK() UNLOCK m.memvar = field1 WAIT WINDOW NOWAIT "Current value of FIELD1 is: " + ; LTRIM(STR(m.memvar)) ENDIF ENDDOThe second workstation's code should be modified to read as follows:
SET EXCLUSIVE OFF SET TALK OFF SET REPROCESS TO <an appropriate interval> USE <database> FOR i = 1 TO 2000 IF RLOCK() REPLACE field1 WITH i UNLOCK WAIT WINDOW NOWAIT "Current value of FIELD1 is: " + ; LTRIM(STR(i)) ENDIF ENDFOR |
Additional reference words: VFoxWin 3.00 FoxDos FoxWin 2.00 2.50 2.50a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |