CalcIt Commands

STRF(Expr, ArrExpr)

This command represents another way to generate formatted strings.

The first parameter (Expr) passes a string with "static" and "variable" parts. The static parts is normal text. The variable parts are represented with the symbol % (placeholder).

The second parameter (ArrExpr) is an array of values that will replace % in the text of the first parameter before STRF return its final result.

s:=strf('Processed % elements from % so far',[10,1000]);

The above code will print on screen the following:

Processed 10 elements from 1000 so far

In the placeholder symbol % it is possible to add formatting commands enclosing them in []:

s:=strf('Processed %[5R] elements from %[5R] so far',[10,1000]);

The formatting commands enclosed in []have to follow symbol % without any space between them. In other case will be considered as normal text.

Additionally, as usually, it is possible to apply formatting commands at the values of the inline array (if an inline array is used in the second parameter):

s:=strf('Processed % elements from % so far',[10:'5R',1000:'5R']);

When the symbol % has to be considered as part of the normal text then is placed as two consecutive %. e.g.

strf('Now at %[3R]%%',[50]);

The above will return:

Now at 5%

See also PRINTF, PRINT, STR, String formatting.

Go Back