Thunderstone Software Document Search, Retrieval, and Management
Search:
Vortex Manual
 

sum - return sum of variable values

 

SYNOPSIS

<sum $fmt $var [$var ...]>


DESCRIPTION
The sum function sums its $var arguments' values - either arithmetically or via string concatenation. The $fmt argument is a <fmt>-style format string that controls how the values are summed, as well as how each value is processed before summing. If $fmt is a string format code (e.g. "%s"), each $var value is printed to a string with $fmt, and the results string-concatenated for a string (varchar) result. If $fmt is a numeric code (e.g. "%d" or "%f"), each $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 type.


DIAGNOSTICS
sum returns the arithmetic sum or string concatenation of its $var arguments, depending on the $fmt code.


EXAMPLE

<$x = 1 2 3>
<sum "%d" $x 4>
$ret
<sum "%10s" "one" "two" "three">
$ret

The output would be (note spacing):

10
       one       two     three


CAVEATS
The sum function was added Sep. 20 1996. In versions prior to Nov 25 1996, the $fmt argument was ignored when concatenating strings.

The $fmt argument should be appropriate for the values' type (numeric or string).


SEE ALSO
fmt strfmt


Copyright © Thunderstone Software     Last updated: Mon Feb 18 10:28:15 EST 2013
 
Home   ::   Products   ::   Solutions   ::   How to Buy   ::   Support   ::   Contact Us   ::   News   ::   About
Copyright © 2013 Thunderstone Software LLC. All rights reserved.