CFLib.org – Common Function Library Project

PlusPlusCounter(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 increment counter.

Return Values:
Returns the value of the variable after it has been incremented.

Example:

<cfset i=0>
<cfset aArray = arrayNew(1)>
<cfset aArray[plusPlusCounter("i")]="Hans">
<cfset aArray[plusPlusCounter("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 after it has been incremented. 
 * @author Stephan Scheele (stephan@stephan-t-scheele.de) 
 * @version 1, April 17, 2002 
 */
function plusPlusCounter(intCounter) {
    "#intCounter#" = evaluate(intCounter) + 1;
    return evaluate(intCounter);
}

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