Home Gadgetman Forum Book Reviews Links Contact me X-UFO
Gadgets Processors Programming School Old news

There are two ways to implement a .ini file:

  1. Text file. This makes it easy to check the file for errors...
  2. database file.
My personal favorite is Database file. This is because of several things: Here's two ways to get the 'last opened file' info(We assume that's the only thing stored in the file) from the .ini file:
(Here we will store the name of the last opened file in the variable lastfile$
   IF EXIST (appdisk$+":\System\Apps\yourapp\yourapp.ini")
      OPEN appdisk$+":\System\Apps\yourapp\yourapp.ini",A,filestring$
      lastfile$=A.filestring$
      CLOSE
   ENDIF
That was the database version...

Here's the text file version.

LOCAL filehandle%,result%
~~~~~~
~~~~~~
   IF EXIST (appdisk$+":\System\Apps\yourapp\yourapp.ini")
      result%=IOOPEN(filehandle%,appdisk$+":\System\Apps\yourapp\yourapp.ini",$20)
      result%=IOREAD(filehandle%,ADDR(lastfile$)+1,255)
      POKEB ADDR(lastfile$),result%
      result%=IOCLOSE(filehandle%)
   ENDIF
Messy or what...

Some might say that the filename should have been built up in a string variable before being used, and that the address of the resultstring could have been calculated before being used. For those: Go ahead! It's your code.

In these examples I have used the appdisk$ variable to open the .ini file on the same disk as the program is stored. This is up to you...
This is NOT what the guides say that you should do... This was written early, before I knew better. (It really should be stored on the RAMdisk C: ) This section hasn't been changed because it demonstrates the use of the appdisk$ variable. Don't forget that if your App uses .OPO modules or other files, they are most likely stored in the same folder as the main .APP file.


<<3 Initialising>>
<<How to build an application>>
<<5. Setting up the Data>>