Write file as character

Command group Flag affected Reversible Execute on client 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 (lPathnameReturns lErrCode
Open file (lPathname,lRefNum
Calculate lCharVar as 'The con of this file was written using the command Write file as character '
Write file as character (lRefNum,lCharVarReturns lErrCode
Close file (lRefNum