Description

Writes data to the specified operating system file.

Syntax

OSWrite expression On | To file

Parameters

The OSWrite statement has the following parameters.

ParameterDescription
expressionPass the string or dynamic array to be written, in expression.
fileThe 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.

ValueMeaning
0No error.
1Bad OS filename.
2Access denied by operating system.
3Disk or directory full.
4File does not exist.
5Unknown error.
6Attempt to write to a read-only file.

See also

OSBReadOSBWriteOSCloseOSDeleteOSOpenOSRead

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
  • No labels