Microsoft KB Archive/98699

{| The information in this article applies to:
 * width="100%"|
 * Microsoft Visual FoxPro for Windows, version 3.0
 * Microsoft FoxPro for Windows, versions 2.5 and 2.5a
 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, and 2.5a

SYMPTOMS
In 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.

CAUSE
To 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 DO WHILE .T.    m.memvar = field1 WAIT WINDOW NOWAIT &quot;Current value of FIELD1 is: &quot; + ; LTRIM(STR(m.memvar)) ENDDO Start the following program on a second workstation: SET EXCLUSIVE OFF SET TALK OFF USE

FOR i = 1 TO 2000 REPLACE field1 WITH i    WAIT WINDOW NOWAIT &quot;Current value of FIELD1 is: &quot; + ; LTRIM(STR(i)) ENDFOR Changes 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.

RESOLUTION
For 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  USE DO WHILE .T.    IF RLOCK UNLOCK m.memvar = field1 WAIT WINDOW NOWAIT &quot;Current value of FIELD1 is: &quot; + ; LTRIM(STR(m.memvar)) ENDIF ENDDO The second workstation's code should be modified to read as follows: SET EXCLUSIVE OFF SET TALK OFF SET REPROCESS TO  USE

FOR i = 1 TO 2000 IF RLOCK REPLACE field1 WITH i      UNLOCK WAIT WINDOW NOWAIT &quot;Current value of FIELD1 is: &quot; + ; LTRIM(STR(i)) ENDIF ENDFOR
 * }

-

Last reviewed: April 29, 1996

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.