basic.write

Statement/BASIC Program, Releases: AP and R83

Writes dynamic array to file.

Syntax

write{x}{u} dynamic.array.variable on {file.variable,} id.expression

Description

writes the item from the dynamic array specified in 'dynamic.array.variable' into the specified file, using the item-id specified in the 'id.expression'.

If the file.variable is not specified, the default file.variable is used.

The 'writeu' statement writes a dynamic array into the specified file.variable and keeps the update lock set. 'writeu' additionally keeps items locked that were locked by a previous 'readu', 'readvu', or 'matreadu' statement.

The 'writex', 'matwritex' and 'matwritexu' statements all have the property of waiting until the actual disk update takes place before continuing execution of the program. They are used for 'critical' write-through, such as error-logging.

Example

write item on customer.file,item.id

This statement unconditionally writes the contents of the array.variable
'item' on the 'customer' file with a specified
'item.id'. If the item doesn't exist, it adds it. If the item
exists, it overwrites it.

readu item from customer.file,item.id else stop
...
begin case
case action = 'fs'
writeu item on customer.file,item.id
case action = 'fi'
write item on customer.file,item.id
return
case action = 'ex'
release customer.file,item.id
return
end case
...

Since a 'writeu' does not clear the item lock, a 'release'
or an explicit 'write' is required to clear the lock before
continuing.

See Also

Command Name Type Description
basic.matwrite Statement Writes dimensioned array to file.
basic.array.references Definition Referencing arrays.
basic.read Statement Reads item into dimensioned or dynamic array.
basic.matread Statement Reads item into dimensioned array.
basic.default.files Definition used by any file-access Pick/BASIC statement when a specific file variable is not specified.
basic.writeu Statement see 'write' or 'matwrite'.
basic.statements Definition Definition of statements and functions.
basic.id.expression Definition An expression which derives an item-id.
basic.file.variable Definition Defines file location from previous 'open' statement.
basic.array.variable Definition References a dimensioned array.
basic.extract Function Extracts element from array.
basic.delete.function Function Deletes element from array.
basic.begin.work Statement Starts a transaction

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.