Forum Discussion

yaacovk's avatar
yaacovk
Contributor
7 years ago
Solved

how to read .ini file

Hi,

 

I want to get user input from .ini file.

According to INI method tutorial, https://support.smartbear.com/testcomplete/docs/reference/program-objects/storages/ini.html  , my .ini file contains [Root] section and Storage extension is enabled (File> Install Extension> Storages under Common section).

However, the simple script doesn't find values option:

ini file

; IMPORTANT: The Root section is required
[Root]

[Settings]
Access=ReadWrite
Type=1

[Temp]
Mask=*.log

 

script function

function ReadIniFile()
{
  var ini = Storages.INI("<path to folder>\config_test.ini");

 
  // Reads the Type value from the Settings section
  value = ini.GetSectionNames()
  Log.Message(value)
  var value = ini.GetSubSection("Settings").GetOption("Type",0);
  Log.Message(value);
  value = ini.GetSubSection("Settings").OptionExists("Type");
  Log.Message(value)
  value = ini.GetSubSection("Temp").OptionExists("Mask");
  Log.Message(value);
}

 

Log messages:


0  
False
False

 

Is there any step missing?

  • I found my mistake: only missed an escaping "\ " for ini file path