CFLib.org – Common Function Library Project

forceWholeQuantityRange(argNum, argMin [, argMax])

Last updated September 27, 2004
Download UDF

author

Shawn Fairweather                                 Shawn Fairweather

Version: 1 | Requires: ColdFusion 5 | Library: UtilityLib

 
Rated 0 time(s). Average Rating: 0

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:

<cfscript>
/**
* 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;
}
</cfscript>

Search CFLib.org


Latest Additions

John Bartlett John Bartlett added
browserDetect
4 day(s) ago

Rob Brooks-Bilson Rob Brooks-Bilson added
listCompare
7 day(s) ago

Stephen Withington Stephen Withington added
formToNameValueP...
15 day(s) ago

anthony petruzzi anthony petruzzi added
parseExcel
20 day(s) ago

Pablo Varando Pablo Varando added
returnRandomHEXC...
21 day(s) ago

Top Rated

Nathan Dintenfass                                 QueryStringChang...
Rated 5.0, 10 time(s)

Stephen Withington formToNameValueP...
Rated 5.0, 5 time(s)

Gyrus                                             HTMLSafe
Rated 5.0, 4 time(s)

Shlomy Gantz                                      viewCSS
Rated 5.0, 4 time(s)

Michael Sharman generateRandomKe...
Rated 5.0, 3 time(s)

Created by Raymond Camden / Design by Justin Johnson