As always, I just created my own function to handle this.
The only thing that makes it incompatible is the [Root] subsection, so I created a procedure that created a new version of an ini and added [Root] to the top.
function CreateTCCompatibleINI(sourceINI,targetINI)
{
//Deletes the file if it exists
aqFile.Delete(targetINI);
//-------------------------------------------------
// Opens source ini for reading
if (aqFile.Exists(sourceINI))
{
var iniFile = aqFile.OpenTextFile(sourceINI, aqFile.faRead, aqFile.ctANSI);
}
else
{
Log.Error("Cannot find " + sourceINI);
}
//-------------------------------------------------
// Opens targetINI for writing
if (!aqFile.Exists(targetINI))
{
aqFile.Create(targetINI);
var testINIFile = aqFile.OpenTextFile(targetINI, aqFile.faWrite, aqFile.ctANSI);
//Writes root to the top of the ini file to make it compatible with Test Complete
testINIFile.WriteLine("[Root]");
}
else
{
var testINIFile = aqFile.OpenTextFile(targetINI, aqFile.faWrite, aqFile.ctANSI);
}
//-------------------------------------------------
//Reads lines from source ini and writes them to target ini
while(!iniFile.IsEndOfFile())
{
var line = iniFile.ReadLine();
testINIFile.WriteLine(line);
Log.Message(line);
}
//-------------------------------------------------
//Closes files so they can be manipulated again.
iniFile.Close();
testINIFile.Close();
}