StrFormat
- Write formatted output to the string

String manipulation
(AmiBroker 4.50)


SYNTAX StrFormat( formatstr, ... )
RETURNS STRING
FUNCTION The StrFormat function formats and returns a series of characters and values in the result string.

If arguments follow the format string, the format string must contain specifications that determine the output format for the arguments.

StrFormat and printf behave identically except that printf writes output to the window, while StrFormat does not write anything to output window but returns resulting string instead.

StrFormat function is useful with conjunction with fputs function that allows to write string to a file.

Note 1: for numbers always use %f, %e or %g formatting, %d or %x will not work because there are no integers in AFL.

Note 2: as of now only numbers and arrays can now be used. For arrays 'selected value' is used

Note 3: to print a single percent-sign character, you can not type % alone, you must use %%.

Starting from version 6.10, printf/StrFormat now implement a check for correct formatting string as sometimes users passed strings with % that is special marker for formatting string instead of %% to print actual percent sign. When check failes, "Error 61. The number of % formatting specifier(s) does not match the number of arguments passed." is displayed

Starting from version 6.20, printf/StrFormat support now "%s" (string specifier)

EXAMPLE fh = fopen("Test.csv", "w" );
for( i = 0; fh && i < 10; i++ )
{
    text =
StrFormat( "Hello world, line %g ", i );
   
fputs( text, fh );
}

fclose( fh );
SEE ALSO printf() function , fputs() function

References:

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

More information:

See updated/extended version on-line.