If you create a program that’s used by different people, you might want to let the user configure the program according to her own preferences. For example, a user might prefer to set the size of the graphics window, or change the background color of the window. One way to let the user change these settings is to save them in what’s called a program’s settings (also called properties, configuration, or initialization) file. A settings file saves special values for a program; your program can use the values stored in this file to initialize some of the variables it uses. For example, instead of setting the width of the GraphicsWindow to 400 pixels inside the program, we can read this value from the settings file. This way, the user can change it.
The settings file’s just a plain text file. You can save any kind of text in it. There’s no standard format, but normally you’d save one setting per line. Each line might contain a string in the form <setting>=<value>
Although you can name the settings files anything you want, the File object provides a method that simplifies dealing with setting files. The GetSettingsFilePath() method returns the full path of the settings file for a program. If your program is C:\Temp\MyApp.exe, this method returns C:\Temp\MyApp.settings.
Do you have any questions? Ask us! We're full of answers and other fine things!
Head to the Small Basic forum to get the most answers to your questions:
And go to http://blogs.msdn.com/SmallBasic to download Small Basic and learn all about it!
Have a Small and Basic day,
- Ninja Ed & Majed Marji