Desolator
06-08-2007, 04:00 PM
I'm creating a database written in a XML file. Now I'm testing what I've done so far, and I get a "table index is nil" error in the following function.
I can't seem to find the error in it, can someone help, please? Here's the code:
function xdbOpenDB(strXdbPath)
-- if there's no database open
if tblXDB == nil then
-- set the number of open databases to zero
local numOpenXDBs = 0;
-- create the database table
tblXDB = {};
-- set the index of the database
local numXdbHandle = 1;
else
-- count the number of open databases
local numOpenXDBs = Table.Count(tblXDB);
-- if the number of open databases is zero
if numOpenXDBs == 0 then
-- create the database table
tblXDB = {};
end
-- set the index of the database
local numXdbHandle = numOpenXDBs + 1;
end
-- add the database path to the table
tblXDB[numXdbHandle] = strXdbPath;
-- return the database index
return numXdbHandle;
end
I attached the project.
I can't seem to find the error in it, can someone help, please? Here's the code:
function xdbOpenDB(strXdbPath)
-- if there's no database open
if tblXDB == nil then
-- set the number of open databases to zero
local numOpenXDBs = 0;
-- create the database table
tblXDB = {};
-- set the index of the database
local numXdbHandle = 1;
else
-- count the number of open databases
local numOpenXDBs = Table.Count(tblXDB);
-- if the number of open databases is zero
if numOpenXDBs == 0 then
-- create the database table
tblXDB = {};
end
-- set the index of the database
local numXdbHandle = numOpenXDBs + 1;
end
-- add the database path to the table
tblXDB[numXdbHandle] = strXdbPath;
-- return the database index
return numXdbHandle;
end
I attached the project.