CFLib.org – Common Function Library Project

CounterMinusMinus([intCounter])

Last updated April 19, 2002

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

 
Rated 3 time(s). Average Rating: 1.0

Description:
Simulate the c functionality of i--. Decrements a counter and returns the value of the counter before it was decremeted.

Return Values:
Returns the value of the variable BEFORE it has been decremented.

Example:

view plain print about
<cfset i=2>
<cfset aArray = arrayNew(1)>
<cfset aArray[counterMinusMinus("i")]="Hans">
<cfset aArray[counterMinusMinus("i")]="Otto">

<cfoutput>
#i#
</cfoutput>

Parameters:

Name Description Required
intCounter The name, not the value, of the variable to be decremented. No

Full UDF Source:

view plain print about
<cfscript>
/**
 * Simulate the c functionality of i--.
 * 
 * @param intCounter      The name, not the value, of the variable to be decremented. 
 * @return Returns the value of the variable BEFORE it has been decremented. 
 * @author Stephan Scheele (stephan@stephan-t-scheele.de) 
 * @version 1, April 19, 2002 
 */

function counterMinusMinus(intCounter) {    
    var temp = evaluate(intCounter);
    "#intCounter#" = temp - 1;
    return temp;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson