Aftershock Web Design Blog
ColdFusion and ini files
23
2006
This morning I was playing around with this blog and noticed Ray had used some functions I was not familiar with. He used getProfileSections(), getProfileString(), and setProfileString(). These functions are used to read and write ini config files. I was so excited, so I started playing around with it before you know it I had made a rough test app for reading/writing an ini file.
One of the things I wanted to be able to change the settings in a form, and I did not want the system to throw an error if a key was missing in the ini file, or in other words if a key was missing, then set it to be "" when loading the form. So here is how it works:
- The administrator loads the form.
- ColdFusion or BlueDragon will read the ini file and load the values into the form.
- If a key is missing, then the value is "".
- Make the changes and save
- The system saves the ini file with the new settings. You don't even need to use cffile!
Below is a link to my test app. There is no validation or error trapping with this; like I said, it is a little rough, but it works. To install, just unzip it inside your webroot, and load in a browser. It should work as is.
All I ask is if you use this and improve it, please share your improvements with me.
Have fun!
