CFLib.org – Common Function Library Project

forceWholeQuantityRange(argNum, argMin[, argMax])

Last updated September 27, 2004

author

Shawn Fairweather

Version: 1 | Requires: CF5 | Library: UtilityLib

Description:
Force a value to whole quantity and restrict to a given min/max range.

Return Values:
Returns a number.

Example:

<cfoutput>
  #forceWholeQuantityRange(1.5, 2, 20)#
</cfoutput>

Parameters:

Name Description Required
argNum The number to check. Yes
argMin The minimum value of the range. Yes
argMax The maximum value of the range. No

Full UDF Source:

/**
 * Force a value to whole quantity and restrict to a given min/max range.
 * 
 * @param argNum      The number to check. (Required)
 * @param argMin      The minimum value of the range. (Required)
 * @param argMax      The maximum value of the range. (Optional)
 * @return Returns a number. 
 * @author Shawn Fairweather (psalm_119_@hotmail.com) 
 * @version 1, September 27, 2004 
 */
function forceWholeQuantityRange(argNum, argMin){
    var qnty = argNum;

    if(IsNumeric(argNum)){
        qnty = int(argNum);
    } else {
        qnty = argMin;
    }

    if(argNum LT argMin){
        qnty = argMin;
    } else if((arrayLen(arguments) gt 2) and (argNum GT arguments[3])){
        qnty = arguments[3];                        
    }
    return qnty;
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson