FPUTS()

From Recital Documentation Wiki
Revision as of 15:21, 27 October 2009 by Helengeorge (Talk | contribs)

Jump to: navigation, search


Purpose

Function to write a character string to an ASCII file


Syntax

FPUTS(<expN1>,<expC1>[,<expN2>][,<expC2>])


See Also

FCLOSE(), FCREATE(), FEOF(), FERROR(), FFLUSH(), FGETS(), FOPEN(), FREAD(), FSEEK(), FWRITE()


Description

The FPUTS() function writes the specified character string to an ASCII file that was created by the FCREATE() function, or opened with the FOPEN() function. The numeric expression <expN1> is the file handle returned by either the FCREATE() or FOPEN() functions, and is used to specify the file that the FPUTS() function writes to.

The character expression <expC1> is the character string that FPUTS() will write to the file. The character string will be placed at the current position of the file pointer. After the string is written to the file, the file pointer is repositioned past the last character of <expC1>.

The FPUTS() function will terminate <expC1> with a default carriage return/line feed on OpenVMS, and a line feed on UNIX/Linux. You may optionally specify a different terminator with character expression <expC2>. Character expression <expC2> must evaluate to one or two characters. The optional numeric expression <expN2> specifies the number of bytes that the FPUTS() function will write from <expC1>. This number must be between 0 and 254.

The FPUTS() function returns the number of bytes, including the end of line terminator, that was written to the file. The FPUTS() function will return a zero if the write was unsuccessful.


Example

fp=fcreate("names.txt")
count=0
do while not eof()
    count= count + fputs(fp,trim(first) + trim(last))
    skip
enddo
dialog box str(count,5) + "written."


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer