Mintoris Forum

Author Topic: Create and read/write INI files  (Read 2117 times)


  • Full Member
  • ***
  • Posts: 26
Create and read/write INI files
« on: Apr 20, 2011, 03:34 AM »
Here is an include file that will create and read/write INI type files to save settings in your program. The format is similar to the Windows INI files with a category heading in brackets e.g. [LASTFILE] followed on the next line by the value for that category.  This uses one value per category. To use, first call BKLoadINI$(INIfile$).  This loads the current INI file into a string array.  To get individual values call BKGetINI$(INI$(),Heading$). If the user changes any values, just update the value in the INI array.  Use a call to BKWriteINI(INIfile$,INI$()) to write the INI array to the INI file.  You can write the INI array to a file at whatever point in your program you deem best, whether each time a value is changed, or at a later time such as when the user clicks an OKAY button.
I have a full implementation of using this posted in the forum's Programs/Utilities section called SrcFormat.bas that you can get a better idea of it's use. In this program a default INI file is written the first time the program is run using default settings in the program.  After the user adjusts the program's settings, the INI array is written to the INI file but retained in the INI array. The next time the program is used the INI file is loaded with the settings last set by the user.  There is room for improvement here, like using delimited strings for the values so that more than one value can be stored in a category….have fun.  / Bill