INI.EraseSection

Top  Previous  Next

 

Syntax

function INI.EraseSection(INIFile: pointer; SectionName: string): boolean

 

Alternative Names

ibec_ini_EraseSection

 

Description

This removes the complete INI-file section identified by SectionName in the given INIFile. A file, if available, isn't modified unless you can INI.UpdateFile.

 

This function Returns TRUE.

 

See also

INI.Create
INI.Clear
INI.Open
INI.UpdateFile
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