INI.WriteString

Top  Previous  Next

 

Syntax

function INI.WriteString(INIFile: pointer; SectionName: string; ValueName: string; Value: string): boolean

 

Description

Write a single string Value to a section identified by SectionName and ValueName in the section. You need to call INI.UpdateFile or INI.SaveToFile to actually write the contents to disk.

 

This function Returns TRUE if the value has been set successfully, FALSE otherwise.

 

See also

INI.ReadInteger
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