PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Robert Eaton on July 09, 2010, 09:18:41 AM

Title: Issue with some ini functions
Post by: Robert Eaton on July 09, 2010, 09:18:41 AM
It seems that for a couple of functions that parse through the ini file, the string read from the file isn't trimmed before being tested. For example FF_INI_GetSectionsList will miss a section that has a space after the right bracket.

Title: Re: Issue with some ini functions
Post by: Rolf Brandt on July 09, 2010, 10:42:23 AM
You are right, Robert.

This is code in the Functions Librarey that causes the effect:

     Line Input #FileID, InputData
     If (Left$(InputData, 1) = "[") And (Right$(InputData, 1) = "]") Then

InputData needs to be trimmed befor processing. If you change the code to this:

     Line Input #FileID, InputData
     InputData = Trim$(InputData)
     If (Left$(InputData, 1) = "[") And (Right$(InputData, 1) = "]") Then

... then it works as expected.

The same would apply for
FF_INI_GetTotalSections
FF_INI_GetTotalKeys
FF_INI_GetSectionKeyList
FF_INI_GetSectionTotalKeys
FF_INI_LineIsSection
Title: Re: Issue with some ini functions
Post by: Paul Squires on July 09, 2010, 10:57:16 AM
The code for the ini functions is very old. Actually, I didn't even write them. I believe that Paul Noble supplied them way back in th every early days of FF1.
Title: Re: Issue with some ini functions
Post by: Roger Garstang on July 16, 2010, 04:12:38 PM
In the WinMobile and .NET worlds Microsoft has completely dropped them all together and went to XML.  I still like INI type files though for simple stuff where XML is bloated. I even store raw Data/Types often in files too.