fputs
- write a string to a file

File Input/Output functions
(AmiBroker 4.50)


SYNTAX fputs( string, filehandle )
RETURNS NOTHING
FUNCTION Writes (puts) the string to the file.

The filehandle must be a number returned by fopen function used to open the file. The file has to be open for writing or appending ("w" or "a") for this fputs to work.

EXAMPLE //
// The following code exports quotes
// of current stock to quotes.csv
// comma separated file
//

fh =
fopen( "quotes.csv", "w");
if( fh )
{
   
fputs( "Date,Open,High,Low,Close,Volume\n", fh );

   y =
Year();
   m =
Month();
   d =
Day();

   
for( i = 0; i < BarCount; i++ )
   {
      ds =
StrFormat("%02.0f-%02.0f-%02.0f,",
                     y[ i ], m[ i ], d[ i ] );
      
fputs( ds, fh );
    
      qs =
StrFormat("%.4f, %.4f, %.4f, %.4f, %.0f\n",
                     
O[ i ], H[ i ], L[ i ], C[ i ], V[ i ] );
      
fputs( qs, fh );
   }

   
fclose( fh );
}


SEE ALSO fopen() function , fclose() function , fgets() function

References:

The fputs function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.