QMWrite |
|
|
The QMWrite function writes a record. This is analogous to the QMBasic WRITE statement.
Format
where
The QMWrite function writes the given data to the file opened as FileNo. If a record with this Id already exists, it is replaced. If the record does not already exist, it is added.
An application should always obtain an update lock on the record before writing it. This function releases the lock.
When writing a new record to a directory file on a Linux or Unix system, the operating system level file that represents the QM record is created using the umask value specified by the UMASK configuration parameter or, if this parameter is not present, a default of 002. This behaviour can be modified by executing a UMASK command either from the LOGIN paragraph or by using the QMExecute() function.
Examples
The above program fragment reads a record with an update lock, modifies it and then writes it back to the file. A real program should test the ErrNo status from the read operations to determine if they were successful.
Note how the C example uses QMFree() to release the dynamic memory allocated to store Rec and Rec2.
|