Write file as character

20% Command group 20% Flag affected 20% Reversible 20% Execute on client 20% Platform(s)
External commands YES NO NO Windows,Linux

Syntax

Write file as character (refnumcharacter-variable [,start-position]) Returns err-code

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This command writes the contents of the specified character-variable to a file. You specify the file reference number returned by Open file in refnum.

If you specify the start-position, writing begins at that absolute character position (0 is the first character in the file, 1 is the second character, and so on), otherwise it begins at the current position (the first character when the file is first opened).

It returns an error code (See Error Codes), or zero if no error occurs.

Example

# write the contents of the character variable 'lCharVar' to a text file
# named 'charfile.txt' in the root of the omnis tree
Calculate lPathname as con(sys(115),'charfile.txt')
Create file (lPathname) Returns lErrCode
Open file (lPathname,lRefNum) 
Calculate lCharVar as 'The contents of this file was written using the command Write file as character'
Write file as character (lRefNum,lCharVar) Returns lErrCode
Close file (lRefNum)