strFmt Function

Formats the specified string and substitutes any occurrences of %n with the nth argument.

str strFmt(str _string, ...)

Parameters

Parameter

Description

_string

The strings to be formatted.

Return Value

The formatted string.

Remarks

If an argument is not provided for a parameter, it will be returned as "%n" in the string.

The string conversion of values of the real type is limited to two decimal places. Values are rounded, not truncated. The System.String::Format method from the .NET Framework can be used to gain additional functionality, as shown in the example.

Example

static void strFmtExampleJob(Args _arg)
{
    System.Double sysDouble;
    real r = 8.3456789;
    int  i = 42;
    utcDateTime utc = str2DateTime
        ("2008-01-16 13:44:55" ,321); // 321 == YMD.
    str  s;
    ;
    s = strFmt("real = %1, int = %2, utcDateTime = %3, [%4]"
        , r, i, utc);
    info("X1:  " + s);
    //
    sysDouble = r;
    s = System.String::Format("{0:##.####}", sysDouble);
    info("N1:  " + s);
    //
    s = System.String::Format("{0,6:C}", sysDouble); // $
    info("N2:  " + s);
/**********  Actual Infolog output
Message (02:16:05 pm)
X1:  real = 8.35, int = 42, utcDateTime = 1/16/2008 01:44:55 pm, [%4]
N1:  8.3457
N2:   $8.35
**********/
}