INI.UpdateFile

Top  Previous  Next

 

Syntax

function INI.UpdateFile(INIFile: pointer): boolean

 

Description

This flushes the contents of the in memory INI-file previously created with INI.Open or INI.Create to disk. Mind you, if you created this INI-file, meaning it doesn't have a name at first, use INI.SaveToFile to set the file name.

 

This function Returns TRUE if the contents is properly flushed to disk, FALSE otherwise.

 

See also

INI.Create
INI.Open
INI.SaveToFile

 

Example

execute udsblock(filepath varchar(500))

returns(testno integer, valueout varchar(2000), valueoutint integer, valueoutdouble double precision)

as

begin

  /* open existing file */

  myini = INI.Open(filepath || existing_ini_file.ini');

 

  /* clear the in memory copy of the file */

  INI.Clear(myini);

  

  INI.WriteString(myini, 'section1', 'value1', '1');

  INI.WriteString(myini, 'section1', 'value2', '2');

  INI.WriteString(myini, 'section2', 'value1', '1');

  INI.WriteString(myini, 'section2', 'value2', '2');

   

  /* get the complete INI as a single string */

  valueout = INI.GetStrings(myini);

 

  /* overwrite complete in memory copy of the file */

  INI.SetStrings(myini, '[section1]' || String.CRLF() || 'value0=2');

  valueout = INI.ReadString(myini, 'section1', 'value0', 'default');

  

  INI.WriteInteger(myini, 'section1', 'intvalue', 666);

  valueoutint = INI.ReadInteger(myini, 'section1', 'intvalue', 0);

  INI.WriteFloat(myini, 'section2', 'floatvalue', 666.66);

  valueoutdouble = INI.ReadFloat(myini, 'section2', 'floatvalue', 0);

 

  /* erase section "section1",  "section2" still exists */

  testno = 5;

  INI.erasesection(myini, 'section1');

  valueout = INI.GetStrings(myini);

  

  INI.UpdateFile();

 

  INI.Free(myini);

end