| WHILE | Index Level | WRITET |
| Syntax | WRITE{X}{U} dynamic.array.variable ON {file.variable,} id.expression {on.error.clause} |
| Category | BASIC |
| Type | Statement |
| 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. On release 7.0 and higher, an optional "on.error.clause" may be specified. This consists of the words "on error" followed by a statement list. The clause is taken if the update fails because the data source is unavailable (as can be the case if the file is remote), or if a callx correlative applied to the file fails because of an "inputerr" statement. |
| Options | |
| See Also | MATWRITE array references READ MATREAD default file variables WRITEU statements & functions id.expression file.variable array.variable EXTRACT DELETE BEGIN WORK INPUTERR callx subroutine |
| 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. |
| Warnings |
{mat}write{u}x is not supported on R83.
If the file updated performs a callx correlative and that subroutine does an "inputerr", then the BASIC program doing the write statement drops immediately to TCL in the default case. If the on.error.clause is present, then that clause is taken in the "inputerr" case. |
| Compatibility | D3 7.0 AP R83 |
| WHILE | Index Level | WRITET |