DADiSP Worksheet Functions > Function Categories > File Manipulation > FPUTS

 

FPUTS

Purpose:

Writes a specified string to a file.

Syntax:

FPUTS("string", "filename", escapes)

"string"

-

A string, the text to write.

"filename"

-

A string, the target file name.

escapes

-

Optional. An integer, the escape character flag to convert "\" escape characters:

0:

do not convert escape characters

1:

convert escape characters (default)

Returns:

A 1 if the write is successful; otherwise it returns nothing.

Example:

fopen("myheader.hdr", "w+");

fputs("DATASET Pressure\n", "myheader.hdr");

fputs("SERIES Pressure_1, Pressure_2\n", "myheader.hdr");

fclose("myheader.hdr");

 

creates a file called myheader.hdr that contains the following information:

 

DATASET Pressure

SERIES Pressure_1, Pressure_2

 

If the file myheader.hdr already existed, its former contents would be lost and replaced by the information shown above.

Remarks:

Must be used with FOPEN and FCLOSE. The last string written to the file must end with '\n'.

 

If escapes is 1 (the default), the escape sequences listed below are automatically converted. Escape sequences are designed to output non-printing characters.

 

 

\n

newline

\t

tab

\b

backspace

\r

carriage return

\f

form feed

\\

backslash

\'

single quote

\ddd

bit pattern

 

 

ddd  d is an octal digit ASCII character with corresponding octal ASCII code.

 

A backslash followed by any other character simply writes the character.

 

See FPRINTF to perform formatted string output to a file.

See Also:

FCLOSE

FGETS

FOPEN

FPRINTF

STRESCAPE