SUM

Contents


"sum" is used to find the total of a series of numerical, or the concatenation of a series of alphanumeric variables.

 

Syntax

   sum( list_exprg )

 

Parameters

Element

Description

Comments

list_exprg

List of expressions_généralisées separated by ','.

The expressions must be of the same type and may not be dates.

 

Examples

   # Sum of several numerical expressions;
   # this programme displays 18.74 if the angular mode is degree
    TOTAL = sum( pi, exp(1), log(24), sqr(2)*2, sin(0.58), 5*3^0.5 )
    Infbox num$(TOTAL)
   # Concatenation of several strings
    Char VILLE(20)
    LIGNE = sum("A ",VILLE,", le ",format$("D:DD[-]MM[-]YYYY",date$),".")
   # Sum of numbers; DELAI_NORMAL and NBRETARD are numerical.
   # RETARD is a numerical table.
    DATE_PREVUE = sum( DELAI_NORMAL, RETARDS(1..NBRETARD) ) + date$

 

Description and comments

"sum" is used to calculate the total of any number of variables or numerical expressions of the same type or the concatenation of string type variables.

For a numerical total, text, decimal, integer, floating point and double variables may be mixed.

If one of the arguments in the function is a dimensioned variable without specifying index or range of indices all the variable elements are used. The index or range of indices specified determines the elements to be considered.

If a range of indices is given, such that there is no element to sum for example sum(VARIABLE(1..0)), the result returned is 0 or an empty string, depending on the type of the variable.

The type of result depends on the type of the arguments, that is:

·         concatenation of strings: the result is a Char type;

·         numerical total: the result is an Integer type (if there are only integers to be totalled), Double (if there is at least one double precision element to be totalled), and otherwise Decimal.

 

Associated errors

Error

Description

ERMODE (10)

The indices given are not numerical.

ERINDI ( 8)

Error in limits for indices.

ERDOM (50)

The arguments are not of the same type.

ERDIM (55)

Too many dimensions given.

 

Associated key words

MIN - MAX - PRD - AVG - VAR - UNI - FIND - SIGMA


CONTENTS


Copyright © Sage 1999 - 2007