CFLib.org – Common Function Library Project

CounterPlusPlus(intCounter)

Last updated April 17, 2002

author

Stephan Scheele

Version: 1 | Requires: CF5 | Library: DataManipulationLib

Description:
Simulate the c functionality of i++. Increments a counter and returns the value of the counter before it was incremeted.

Return Values:
Returns the value of the variable BEFORE it was incremented.

Example:

<cfset i=1>
<cfset aArray = arrayNew(1)>
<cfset aArray[counterPlusPlus("i")]="Hans">
<cfset aArray[counterPlusPlus("i")]="Otto">

<cfoutput>
#i#
</cfoutput>

Parameters:

Name Description Required
intCounter The name, not the value, of the variable to be incremented. Yes

Full UDF Source:

/**
 * Simulate the c functionality of i++.
 * 
 * @param intCounter 	 The name, not the value, of the variable to be incremented. 
 * @return Returns the value of the variable BEFORE it was incremented. 
 * @author Stephan Scheele (stephan@stephan-t-scheele.de) 
 * @version 1, April 17, 2002 
 */
function counterPlusPlus(intCounter){
	var temp = evaluate(intCounter);
	"#intCounter#" = temp + 1;
	return temp;
}
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