INI.ReadString

Top  Previous  Next

 

Syntax

function INI.ReadString(INIFile: pointer; SectionName: string; ValueName: string; Default: string): string

 

Alternative Names

ibec_ini_ReadString

 

Description

Read a single string value from a section identified by SectionName and ValueName in the section.

 

This function Returns the found value or Default if the value cannot be found.

 

See also

INI.WriteInteger

 

 

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