Limit

(Engine-Level Function)

Description Set Value Minimum and Maximum. This function returns a value that is limited both on the high and low ranges.
Returns Numeric
Usage Script or steady state.
Function Groups Rounding Math
Related to: Max | Min
Format: Limit(X, Low, High)
Parameters  
X  
Required. The variable whose numeric value will be limited.
Low  
Required. Any numeric expression giving the lower limit for the value X.
High  
Required. Any numeric expression giving the upper limit for the value X.
Comments This function performs the same operation as Min(High, Max(Low, X)) but is simpler to write and requires less memory. If the value exceeds one of the limits, the function returns that limit. Otherwise, the value is returned unchanged. If Low is greater than High, the value for High is returned. If any of the parameters is invalid, the function returns invalid.

Examples:

a = Limit(123.4, 0, 100);
b = Limit(-2.6, 0, 100);
c = Limit(36.7, 0, 100);
d = Limit(36.7, Invalid, 100);

The values for a, b, c, and d are 100, 0, 36.7 and invalid, respectively.