<sum $fmt $var [$var ...]>
sum function sums its
$var arguments' values -
either arithmetically or via string concatenation. The
argument is a
<fmt>-style format string that controls how the
values are summed, as well as how each value is processed before
$fmt is a string format code (e.g. "
$var value is printed to a string with
the results string-concatenated for a string (
$fmt is a numeric code (e.g. "
$var value is cast to the type indicated
by the code (with all integer types promoted to
int64), and the
results arithmetically summed, for a numeric result of the same
sum returns the arithmetic sum or string concatenation of its
$var arguments, depending on the
<$x = 1 2 3>
<sum "%d" $x 4>
<sum "%10s" "one" "two" "three">
The output would be (note spacing):
one two three
sum function was added Sep. 20 1996. In versions prior
to Nov 25 1996, the
$fmt argument was ignored when
$fmt argument should be appropriate for the values' type
(numeric or string).
sum function is implemented as a user function, so its
arguments are converted to strings by Vortex (perhaps via Texis SQL
type conversion) before it starts. Thus, some floating point
arguments may lose precision.