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;
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson