WRITEU Statement

The WRITEU statement writes an item into a file, leaving an existing item lock or will save an item lock if one does not exist.

Format

WRITEU expr ON [filevar,] item-ID

Description

The WRITEU statement is identical to the WRITE statement, except that an existing item lock is not released by the WRITEU 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 WRITEU.

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 WRITEU 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 new record 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.

READU CUST.REC FROM CUSTFILE,ID ELSE

   PRINT "COULD NOT READ ITEM"

END

PRINT "ENTER THE NEW PHONE NUMBER: ":

INPUT NEW.PHONE

CUST.REC<6> = NEW.PHONE

WRITEU CUST.REC ON CUSTFILE,ITEM.ID    

PRINT "ANY OTHER CHANGES TO THE RECORD?" :

See Also

Statement and Function Reference