This topic has not yet been rated Rate this topic

strFmt Function

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


str strFmt(str _string, ...)

Parameter

Description

_string

The strings to be formatted.

The formatted string.

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.

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
**********/
}
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Naresh Ax Sample codes
PRINT MULTIPLICATION TABLE

static void MultipTab(Args _args)
{
int i,j;
int r ;
;
j = 5;
r = i*j;
for (i = 1; i <=10; i++)
{
print strfmt("%1 * %2 = %3",j,i, i*j);
}
pause;
}

ADDITION OF TWO NUMBERS

static void Addition(Args _args)
{
int a,b,c;
;
a = 10;
b = 20;
c = a+b;
print strfmt("The value of c is %1",c);
pause;
}