Description
Writes data to the specified operating system file.
Syntax
OSWrite expression On | To file
Parameters
The OSWrite statement has the following parameters.
Parameter | Description |
---|---|
expression | Pass the string or dynamic array to be written, in expression. |
file | The name of the operating system file (including the path, filename, and extension) to which expression is to be written. This is not a file variable. If the operating system file exists, it will be overwritten with the new data. If the operating system file does not exist, it will be created. |
Returns
After the execution of an OSWrite statement, the Status() of the write is returned, with one of the following codes.
Value | Meaning |
---|---|
0 | No error. |
1 | Bad OS filename. |
2 | Access denied by operating system. |
3 | Disk or directory full. |
4 | File does not exist. |
5 | Unknown error. |
6 | Attempt to write to a read-only file. |
See also
OSBRead, OSBWrite, OSClose, OSDelete, OSOpen, OSRead
Example
/* write a file containing tab-delimited data */ equ crlf$ to char(13):char(10) equ tab$ to char(09) data = "" data<-1> = "Tom":@vm:"Charles":@vm:"Administrator" data<-1> = "Will":@vm:"Roberts":@vm:"System Administrator" data<-1> = "Adrian":@vm:"Wilson":@vm:"User" swap @fm with crlf$ in data swap @vm with tab$ in data filename = 'C:\temp\my_data.txt' OSWrite data To filename