basically an INI file looks like: [Section] key=value
You need two functions to write to and read from an inifile
Those functions are: GetPrivateProfileString and WritePrivateProfileString
Both reside in the Kernel32
WritePrivateProfileString has 4 parameters cSectionName cKeyname cValueToStore cPathAndnameOfIniFile
GetPrivateProfileString has 6 parameters cSectionName cKeyname cDefaultReturnValue cBufferWhereReadValueIsStored nLengthOfBuffer cPathAndnameOfIniFile It returns an integer, deining the number of read characters.
Therefore the syntax to declare either function is Declare Integer GetPrivateProfileString in Kernel32 ; string, string, string, string @, integer, string
DECLARE integer WritePrivateProfileString in Kernel32 ; string, string, string, string
To place a value in the inifile (assumed MyIniFile.ini in the current directory) ?WritePrivateprofileString("MySection","MyKey","Key1Value",addbs(fullpath(curdir()))+"MyIniFile.ini")
if a 1 is returned, writing was succesful, a 0 (zero) indicates a failure. The integer is actually a boolean value. Out of the blue, automagically there is a MyIniFile.ini in the directory, created by this call.
It should look like: [MySection] Mykey=Key1Value
To read the value: lcBuffer = space(255) ?GetPrivateProfileString( "MySection","MyKey","",@lcBuffer, Len(lcBuffer), addbs(fullpath(curdir()))+"MyIniFile.ini")
The returned value indicates the number of bytes read. There are two more things we need to do: Strip of the trailing chr(0) with lcBuffer = strtran(lcBuffer,chr(0),"") and trim it lcBuffer = alltrim(lcBuffer)