//by Richard Russell, May 2006//\\ \\ You may want your program to read configuration settings or user options on start up, to avoid the user having to enter them every time. One way of doing that is to use the //​registry//,​ and this is described in the main help documentation [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwine.html#​registry|here]].\\ \\ However there may be reasons why you prefer not to use the registry, for example you might like the configuration settings to be in a file which can be easily read and edited, and even transferred between different computers. In that case you can store the data in a **.INI** file, which is a text file in a standardised format. Here is an example of a .INI file:\\ \\

//by Richard Russell, May 2006//\\ \\ You may want your program to read configuration settings or user options on start up, to avoid the user having to enter them every time. One way of doing that is to use the //​registry//,​ and this is described in the main help documentation [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwine.html#​registry|here]].\\ \\ However there may be reasons why you prefer not to use the registry, for example you might like the configuration settings to be in a file which can be easily read and edited, and even transferred between different computers. In that case you can store the data in a **.INI** file, which is a text file in a standardised format. Here is an example of a .INI file:\\ \\

+

<code ini>

[settings]

[settings]

aspect=1

aspect=1

Line 15:

Line 16:

compressor=mp4v

compressor=mp4v

quality=512

quality=512

+

</​code>​

The file consists of a number of sections (here they are **settings** and **codec**) and within each section are one or more lines in the format "​key=value"​. Windows makes it very easy to use such files because it provides API routines to access them.\\ \\ To read data from a .INI file you can use the following function:\\ \\

The file consists of a number of sections (here they are **settings** and **codec**) and within each section are one or more lines in the format "​key=value"​. Windows makes it very easy to use such files because it provides API routines to access them.\\ \\ To read data from a .INI file you can use the following function:\\ \\

Here it is assumed that the file resides in the user's **Documents** folder. You should always specify a full path to the file.\\ \\ Arguably, a better place to store the file would be the user's **Application Data** folder, which you can do as follows:​\\ ​

Here it is assumed that the file resides in the user's **Documents** folder. You should always specify a full path to the file.\\ \\ Arguably, a better place to store the file would be the user's **Application Data** folder, which you can do as follows:​\\ ​

The **FNspecialfolder** routine is listed in the main Help documentation [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwine.html#​specialfolders|here]].\\ \\ The above examples retrieve the data as a string. If you know that the data will be an integer, then a simpler form can be used:\\ \\

The **FNspecialfolder** routine is listed in the main Help documentation [[http://​www.bbcbasic.co.uk/​bbcwin/​manual/​bbcwine.html#​specialfolders|here]].\\ \\ The above examples retrieve the data as a string. If you know that the data will be an integer, then a simpler form can be used:\\ \\

The value **default%** is returned in the case where the section or key does not already exist in the .INI file, such as when first running a program. There is no equivalent system call for writing of integers and the method below should be used.\\ \\ To write data to (and if necessary create) a .INI file you can use the following procedure:​\\ \\

The value **default%** is returned in the case where the section or key does not already exist in the .INI file, such as when first running a program. There is no equivalent system call for writing of integers and the method below should be used.\\ \\ To write data to (and if necessary create) a .INI file you can use the following procedure:​\\ \\