CFLib.org – Common Function Library Project

parseINI(codefile)

Last updated April 14, 2011

author

Dave Long

Version: 1 | Requires: CF8 | Library: CFMLLib

Description:
parseINI parses an INI file into a structure that contains sections and keys as structures.

Return Values:
Returns a struct.

Example:

<cfscript>
     inifile = 'C:/myboot.ini';
     inistruct = parseINI(inifile);
     writeDump(inistruct);
</cfscript>

Parameters:

Name Description Required
codefile FIle to read. Yes

Full UDF Source:

/**
 * Parses an INI file into a structure.
 * 
 * @param codefile 	 FIle to read. (Required)
 * @return Returns a struct. 
 * @author Dave Long (dave@davejlong.com) 
 * @version 1, April 14, 2011 
 */
function parseINI(string codefile) {
	var i = '';
	var codes = structNew();
	local.sections = getProfileSections(arguments.codefile);
	for(local.section IN local.sections){
		codes[local.section] = structNew();
		local.keys = local.sections[local.section];
		for(i=1;i LTE listLen(local.keys);i++){
			codes[local.section][listGetAt(local.keys,i)] = getProfileString(arguments.codefile,local.section,listGetAt(local.keys,i));
		}			
	}
	
	return codes;
}
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