proftostruct
Example Output
  Source of example config file (profToStruct.ini)
[Section1]
s1_key1=one
s1_key2=two
s1_key3=three

[Settings]
Settings1=one
Settings2=two
Settings3=three

[Settings.Nested]
Ex1=one
Ex2=two
Ex3=three

[Settings.Nested.Deeper]
Deep1=one
Deep2=two
Deep3=three

[Settings.Nested.Deeper.Even]
Deeper=as
Deeper=Deep
Deeper=as
Deeper.You.Val=Want
Deeper.You.Want.Val=To
Deeper.You.Want.Deep=go
Turns into this - struct
section1
Turns into this - struct
s1_key1 one
s1_key2 two
s1_key3 three
settings
Turns into this - struct
nested
Turns into this - struct
deeper
Turns into this - struct
deep1 one
deep2 two
deep3 three
even
Turns into this - struct
deeper
Turns into this - struct
you
Turns into this - struct
val Want
want
Turns into this - struct
deep go
val To
ex1 one
ex2 two
ex3 three
settings1 one
settings2 two
settings3 three
        
Source code <div class="Source"> <pre> <span class="Label">Source of example config file (profToStruct.ini)</span> <cfinclude template="profToStruct.ini"> </pre> </div> <cfdump var="#profToStruct("#GetDirectoryFromPath(GetCurrentTemplatePath())#profToStruct.ini")#" label="Turns into this"> <cfscript> function profToStruct(confile) { // Creates nested structs from profile // @param |String|Required : Config filename. // Return (Struct): Struct based on profile settings. // Author Raymond Compton - usaRaydar@gmail.com // 2007.1.1 var v = structNew(); v.Return = structNew(); v.ConFile = ConFile; v.Sections = getProfileSections(v.ConFile); v.SectionList = structKeyList(v.Sections); for ( v.i = 1; v.i lte listLen(v.SectionList); v.i = v.i + 1 ) { // Loops over Sections v.Section = listGetAt(v.SectionList,v.i); v.Keys = evaluate('v.Sections.#v.Section#'); for ( v.ii = 1; v.ii lte listLen(v.Keys); v.ii = v.ii + 1 ) { // Loops over Keys v.Key = listGetAt(v.Keys,v.ii); "v.Return.#v.Section#.#v.Key#" = getProfileString(v.ConFile,v.Section,v.Key); } } return v.Return; } </cfscript>
© 2017 usaRaydar
v.
IP:23.20.86.177 css:/assets/css/raycomweb.css?v=16021511