FORMAT - format a string or number.

FORMat(X,[I1,I2,S1,S2]) returns S

is similar to the "printf" function of B or C. It formats a string or numeric value and returns a string which contains the formatted number.

X is the value you want to format. This can be a number or string.

I1 gives the width of the formatted value. This is the minimum number of characters that you want the value to occupy. If the value of X does not fit in this number of characters, FORMat uses more characters.

I2 gives the "precision" of the formatted value. The function of the precision depends on the type of data being formatted. See the description of precisions in "expl b lib printf" for further details.

S1 is a string giving a series of flags, similar to those of "printf", and also a single character indicating the output format you want. FORMat recognizes the following flags:

+        print '+' or '-' in front of numbers
blank    print '-' for negative, ' ' for positive
-        left justify value
0 (zero) print leading zeroes
#        print in verbose format
a        same as "printf" %_a format (string)
d        decimal (numeric)
e        exponential floating point (numeric)
f        normal floating point (numeric)
g        "printf" %g (numeric)
o        octal (numeric)
s        string (string only)
u        unsigned decimal (numeric)
x        hexadecimal (numeric)

For further details (e.g. a definition of verbose format), see "expl b lib printf". Flags can be arranged in any order, so "+d" is equivalent to "d+". One and only one flag must be a letter. If S1 is omitted, or no conversion code is specified, a default of 'd', 'g' or 's' will be chosen.

S2 is a string giving a fill character. This character is used to fill out the formatted value to the width given by I1 (if necessary).

The value to be formatted must always be the first argument of FORMat. After that, the first two numeric arguments are taken as the width and the precision (respectively) and the first two string arguments are taken as the flags and fill character (respectively). This means, for example, that the flags may come before the width value. You may omit the width, precision, and fill arguments.

Copyright © 1996, Thinkage Ltd.