Writing Sections and Options to an INI File. Example

Applies to TestComplete 14.90, last modified on June 15, 2021

The following code creates a new INI file and gets a FileSection object for the root section of this file. Then, it creates a subsection in this section and an option in this subsection.

JavaScript, JScript

function TestProc()
{
  var w, Section;
  w = Storages.INI("C:\\testini.ini");
  Section = w.GetSubSection("New Subsection");
  Section.SetOption("New Option", 1234);
  w.Save(); }

Python

def TestProc():
  w = Storages.INI("C:\\testini.ini")
  Section = w.GetSubSection("New Subsection")
  Section.SetOption("New Option", 1234)
  w.Save()

VBScript

Sub TestProc
  Set w = Storages.INI("C:\testini.ini")
  Set Section = w.GetSubSection("New Subsection")
  Section.SetOption "New Option", 1234
  w.Save
End Sub

DelphiScript

procedure TestProc;
var w, Section: OleVariant;
begin
  w := Storages.INI('C:\testini.ini');
  Section := w.GetSubSection('New Subsection');
  Section.SetOption('New Option', 1234);
  w.Save;
end;

C++Script, C#Script

function TestProc()
{
   var w, Section;
   w = Storages["INI"]("C:\\testini.ini");
   Section = w["GetSubSection"]("New Subsection");
   Section["SetOption"]("New Option", 1234);
   w["Save"]();
}

Highlight search results