Forum Discussion
mijex71989
14 years agoOccasional Contributor
Hello,
The
The
CurrentDriver property holds a reference to the last created DDTDriver object (in your script, it is Driver2). So, after you close Driver2, Driver2 no longer holds a reference to the driver and the error you mention occur. Use DDT.DriverByName instead:
function dbtest(fname)
{
var f1name = "C:\\TestData\\" + fname + ".txt";
// Creates the driver
var Driver2 = DDT["CSVDriver"](f1name);
// Iterates through records
while (! Driver2["EOF"]() )
{
AppScriptDriver();
Driver2["Next"]();
}
// Closing the driver
DDT["CloseDriver"](Driver2["Name"]);
}
function DbMasterBatchController()
{
var Driver1;
// Creates the driver
Driver1 = DDT["CSVDriver"]("C:\\TestData\\MBA.txt");
// Iterates through records
while (! Driver1["EOF"]() )
{
fname = DDT["DriverByName"](Driver1["Name"])["Value"](1);
dbtest(fname);
Driver1["Next"]();
}
// Closing the driver
DDT["CloseDriver"](Driver1["Name"]);
Log["Warning"]("Driver closed");
}