WRITEU Statement

Writes a variable, as a dynamic array, to a file item, leaving a previously locked item locked after the write.

Syntax

WRITEU string [ON || TO] {file-var,}item-id {SETTING setting-var} {ON ERROR statement(s)}

Syntax Elements

string is the data to be written, comprising a field of characters expressed as a variable name, a dynamic array reference, or a literal string in quotes.

file-var is the name of a variable containing a file reference (assigned via an OPEN statement). If file-var is not specified, the internal default file variable is used; that is, the file used is that most recently opened without a file variable.

item-id is the name of the item to which the data is written.

setting-var is the name of a variable that is set to a value corresponding to a file I/O error code by the SETTING clause if the item cannot be written to and the ON ERROR clause is taken. For a description of file I/O error codes, refer to File I/O and IPC Error Codes.

If the ON ERROR clause is not taken, setting-var is set to 0.

ON ERROR operates the same as an ELSE clause.

Note

It is recommended that you always include an ON ERROR clause. If you do not and an error occurs at run time, your program will abort. This is particularly important if the file has a PRE-WRITE trigger that may cancel the WRITEU operation.

statement(s) is a sequence of one or more valid DataBasic statements, either separated by semicolons or contained on separate lines and followed by an END statement. These will be executed if an error occurs.

Operation

The WRITEU statement functions the same as the WRITE statement except that it leaves a previously locked item locked after the write operation.

Note

WRITEU does not actually lock an item.  It simply does not unlock an item that is already locked.  If the item is not locked, WRITEU is identical to WRITE.

Caution

When calling this statement, you need to be aware of the effects of any file triggers that might run as a consequence. See File Triggers for more information.

Examples

WRITEU "XYZ" ON FILEA, ITEM4

Replaces the current contents of ITEM4 in FILEA with the string XYZ.  If ITEM4 was locked previously, it remains locked after the write.

WRITEU 20*4 ON "REC"

Replaces the current contents of item REC in the file most recently opened without a file variable with string value 80.  If REC was already locked, it remains locked after the write.