The WRITEVU statement writes a single attribute of a file item into a file, leaving an existing item lock set or will set an item lock if one does not exist.
Format
WRITEVU expr ON [filevar,] item-ID, attr# |
Description
The WRITEVU statement is identical to the WRITEV statement, except that an existing item lock is not affected by the WRITEVU statement. An item will be set if one does not already exist before the item is written to the file. See WRITE Statement for more information on the syntax for WRITEVU.
The SET-WRITE-LOCK system switch controls whether the WRITEU, MATWRITEU, WRITEVU and WRITEFU statements in mvBASIC set an item lock if an item lock is not already set. Refer to the SET-WRITE-LOCK system switch in the Guide to mvBase Files and Accounts for additional information.
NOTE |
The setting of an item lock by the WRITEVU statement can be disabled by setting the SET-WRITE-LOCK system switch to state R91. To enable this function, set the state to MENTOR (the default setting). |
Example
In this application, Attribute 6 contains the customer’s phone number. A new phone number is prompted for and then placed into Attribute 6. The attribute is then written back into the file, but the file item lock is not lifted; subsequent changes may be made to the record and written into the file without danger of being overwritten by a concurrent program.
READVU PHONE FROM CUSTFILE.ID, 6 ELSE PRINT "ERROR: COULD NOT ACCESS" END PRINT "NUMBER IS ":PHONE PRINT "IS THIS CORRECT? (Y OR N)" IF ANSWER = "N" THEN PRINT "ENTER THE NEW PHONE NUMBER: ": INPUT .PHONE WRITEVU PHONE ON CUSTFILE, ID 6 PRINT "ANY OTHER CHANGES TO THE RECORD?" : . . END |
See Also