# Error Messages/40512

## Contents

## Examples of message

In the call to function Bernoulli, the first parameter, «p», should be greater than or equal to zero, but the array passed for this parameter contains a value that is either negative or non-numeric at coordinate: Time = 2012 Plant = 'N337'

General form of the message:

In the call to function «fn», the «nth» parameter, «name», should be greater than or equal to zero, but the array passed for this parameter contains a value that is either negative or non-negative at coordinate: «coord»

## Cause

You are calling a function, where the *n*^{th} parameter is declared as NonNegative. You are passing an array of values to this parameter, and at least one of those values, the one at the indicated coordinate of the array, contains a value that is either non-numeric (e.g., textual, Null, etc), or is negative.

Alternatively, this error may also occur when an index (which was intended to have numeric values) is defined as a list-of-labels, rather than as a list -- looking like numeric values, but in fact text values like: `['0%', '10%', ...]`

.

## Remedies

Try copying and pasting the expression for the *n*th parameter into a different variable, say `Va1`

. Then view its result table and find the coordinate that was listed in the error message. This will help you determine what the value is, and from there you can trace back to figure out why.

Suppose you'd like to call the function for all the non-negative numeric cases, and just return Null for those cases that violate the parameter declaration.

If there is only one parameter at fault, and if that parameter expects a scalar, you could replace the original call:

`F(..., someExpr,...)`

with

`Var tmp[] := someExpr Do If IsNumber(tmp) and tmp >= 0 then F(..., tmp,...) else Null`

If the parameter at fault expects an array indexed by `I, J`

, the same trick can be adapted like this:

`Var tmp[I, J]:=someExpr Do If Min(IsNumber(tmp) and tmp >= 0, I, J) then F(...,tmp,...) else Null`

Notice that `F`

gets called only if every element in the `I, J`

slice is non-negative and numeric.

If more than one parameter is bad, rather than extend the above trick with several Var..Do declarations, for each parameter, it is slightly more efficient to create a user-defined wrapper function, having the same parameter declaration as the original, but with the non-negative qualifier removed. For the example of Binomial, this would be:

`Function MyBinomial(n, p: atomic; over:...optional atomic)`

`Definition: If IsNumber(p) and IsNumber(n) and and p >= 0 and n >= 0 then Binomial(n, p) else Null`

This is slightly more efficient than multiple Var..Do declarations because the function call can coordinate the iteration over any indexes shared between `n`

and `p`

. In the original Binomial, both `n`

and `p`

are declared as NonNegative.

If the index was defined as a list-of-labels, rather than as a list, select the definition and change the definition type pulldown from "list of labels" to just "list". Then remove the quotes.

Enable comment auto-refresher