2.5.4.14 Bound

The Bound function constrains a value by one or more ranges.

ABNF:

 Bound = val val 1*(val val val) sp unsigned-integer-value ";BOUND():129"

Required Arguments:

Name: Number

Type: vDouble

An argument that specifies the value to be constrained.

Name: BoundType

Type: vUnsignedInt

An argument that specifies the bounding type.  The valid values are described in the following table.

Value

Meaning

0

Constrain Number inclusive of any of the ranges specified

1

Constrain Number exclusive of all the ranges specified

2

Do not constrain Number

Name: IgnoreRange

Type: PtgBool

An argument that specifies if this range is not included in constraining Number.

Name: ValueBeg

Type: vDouble

An argument that specifies the beginning value of the range.

Name: ValueEnd

Type: vDouble

An argument that specifies the ending value of the range.

Optional Arguments:

Additional ranges MUST be specified using 1 or more additional groups of IgnoreRange, ValueBeg, and ValueEnd.

Return Value:

Type: vNum, PtgErr

This function returns a vNum containing the constrained value of Number, as described in the following table.

Condition

Result

BoundType = 0

If Number is in at least one range with IgnoreRange equal to FALSE, the function returns Number.

Otherwise, consider the set of all ValueBeg and ValueEnd values that belong to a range with IgnoreRange equal to FALSE. The function returns the value in this set that is closest to Number. If more than one value has the same minimum distance from Number, the function returns the value in this set that has minimum distance from Number and that appears earliest in the argument list.

BoundType = 1

If Number is not in any range with IgnoreRange equal to FALSE, the function returns Number.

Otherwise, consider the set of all ValueBeg and ValueEnd values that belong to a range with IgnoreRange equal to FALSE and that are not nested inside another range with IgnoreRange equal to FALSE. The function returns the value in this set that is closest to Number. If Number is in the exact middle of a ValueBeg value and a ValueEnd value in this set, the function returns the ValueEnd value.

BoundType = 2

The function returns Number.

Otherwise

The function returns a PtgErr with an error code of #VALUE!.

If Number is a vAngle, the return value is normalized to be greater than or equal to zero and less than 2*pi. The unit of the return value is equal to the unit of Number. If Number is a ptgPnt or the wrong number of arguments is used, the function returns a PtgErr with an error code of #VALUE!.