listOfSections = structKeyList(getProfileSections(inifile.ini))
I've done such a thing. Let me see if I can dig up my code...
<cffunction name="loadFromINI" access="public" output="false"
returntype="struct" hint="Given a fully-qualified path to an *.ini file,
returns a structure with the key/value pairs in that file. If useGroups
is true, uses the group name(s) to create a structure of structures.">
<cfargument name="pathToINI" required="yes" type="string">
<cfargument name="useGroups" default="true" type="boolean">
<cfset var local=structNew()>
<cfset local.returnStruct=structNew()>
<cfset
local.sectionStruct=getProfileSections(arguments.pathToINI)>
<cfloop collection="#local.sectionStruct#" item="local.item">
<cfset local.workingStruct=structNew()>
<cfloop list="#local.sectionStruct[local.item]#"
index="local.key">
<cfset
local.workingStruct[local.key]=getProfileString(arguments.pathToINI,loca
l.item,local.key)>
</cfloop>
<cfif arguments.useGroups>
<cfset
local.returnStruct[local.item]=duplicate(local.workingStruct)>
<cfelse>
<cfset
structAppend(local.returnStruct,local.workingStruct,"yes")>
</cfif>
</cfloop>
<cfreturn local.returnStruct>
</cffunction>
I then generally add this structure to the application scope.
HTH
-----Original Message-----
From: James Buckingham [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 11, 2007 10:13 AM
To: CF-Talk
Subject: List of Sections from an initialisation file
Hi everyone,
Is there any way that I can get a list of all the sections within an ini
file through ColdFusion?
If I use getProfileSections and dump it I'm seeing each section + all
the variables included with them. All I want, for now, is the section
names.
What I'm looking to do is setup a simple dynamic loop which uses the
list to grab each section, insert its variables into a struct and place
this in my application. That way if I add a new section to the ini. file
I don't have to worry about extending my CF code to accommadate it.
Or is there an easier way I could be doing this?
Cheers,
James
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:266252
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4