Page 1 of 1

Using INI files => libini

Posted: Sun Dec 21, 2014 9:32 pm
by Pablo C├ęsar
Collecting experiences and sharing...

Our code for INI files is based on Grigory Filatov and Janusz Pora code.

Is got to mention that its support for types:

Character/Memo, Numeric, Date, Logical, Array and CodeBlocks too :)

_GetIni brings in that kind of types but is very important to previous create all variables or in arrays accordingly it types and values (not just declared neither as Nil). Otherwise aways will bring as character or most probably without empty value.

Normally we use like this:

Code: Select all

BEGIN INI FILE (cExeFPath + "Stru.ini")
      GET cFixedLang SECTION "Default" ENTRY "Language"
      GET cRDD       SECTION "Default" ENTRY "RDD"
      GET cBorders   SECTION "Default" ENTRY "Borders"
      GET cBPreview  SECTION "Default" ENTRY "Preview"
END INI
I have recently used like this:

Code: Select all

BEGIN INI FILE (cExeFPath + "Stru.ini")
      cFixedLang := _GetIni( "Default", "Language",, cFixedLang )
      cRDD       := _GetIni( "Default", "RDD",, cRDD )
      cBorders   := _GetIni( "Default", "Borders",, cBorders )
      cBPreview  := _GetIni( "Default", "Preview",, cBPreview )
END INI
This way I force the right use I in the parameter not informed I culd let a default value when its return back a empty value.

Leaving registered the tip ! I hope be useful. :D