PDA

View Full Version : problem returning tables



screwed over
03-25-2008, 03:59 PM
I am having some problem with one of my functions:
function CheckLogin(User, Pass)
if File.DoesExist(_WindowsFolder.."\\omGOD DC\\Logins\\"..User..".oel") then
sFold = _TempFolder.."\\omGOD DC\\";
Crypto.BlowfishDecrypt(_WindowsFolder.."\\omGOD DC\\Logins\\"..User..".oel", _TempFolder.."\\"..User..".zip", "pass");
Zip.Extract(_TempFolder.."\\"..User..".zip", {"User.ini"}, _TempFolder.."\\omGOD DC\\"..User, true, true, "pass", ZIP_OVERWRITE_ALWAYS, nil);
ePass = INIFile.GetValue(_TempFolder.."\\omGOD DC\\"..User.."\\User.ini", "UserData", "pDesc");
dPass = Decrypt(ePass);
if Pass == dPass then
Zip.Extract(_TempFolder.."\\"..User..".zip", {"*.*"}, _TempFolder.."\\omGOD DC\\"..User, true, true, "pass", ZIP_OVERWRITE_ALWAYS, nil);
ldTable = {}
ldTable.Correct = true;
ldTable.uPic = _TempFolder.."\\omGOD DC\\"..User.."uPic.img";
ldTable.pDesc = INIFile.GetValue(_TempFolder.."\\omGOD DC\\"..User.."\\User.ini", "UserData", "pDesc");
ldTable.uName = User;
return ldTable
end
else
ldTable = {}
ldTable.Correct = false;
return ldTable
end
end

For some reason it wont return ldTable,and instead i get a nil value (currently only ldTable.Correct though i cant check the others if that wont work until that one does). I dont see why because i have returned tables before in the same way.

Any help would be appreciated.

longedge
03-25-2008, 04:11 PM
Is this a function defined somewhere else? "dPass = Decrypt(ePass);"

screwed over
03-25-2008, 04:17 PM
yeh, its a custom encryption and decryption function (not releasing as i use it alot). I know that function works because i spent a couple of months writing and debugging every last part of it.

Desmond
03-25-2008, 05:01 PM
In the logic above, if the file exists, but the decrypted pass doesn't equal the pass, nothing will be returned.

What if you initialize ldTable at the start of the function, and set ldTable.Correct = false as a default value. Then set it to true where required. At the end of your function, after all comparisons, return the value of ldTable ... ldTable.Correct will be false, unless one of your conditions modifies it.

So in essence:


function CheckLogin(User, Pass)
ldTable = {};
ldTable.Correct = false;
if (something == something2) then
ldTable.Correct = true;
end
return ldTable;
end

Can you construct a similar case to the above to confirm the table is in fact being returned? Once you get that working ... add in the more complex stuff.

Desmond.

RizlaUK
03-25-2008, 05:24 PM
this should fix it:


function CheckLogin(User, Pass)
if File.DoesExist(_WindowsFolder.."\\omGOD DC\\Logins\\"..User..".oel") then
sFold = _TempFolder.."\\omGOD DC\\";
Crypto.BlowfishDecrypt(_WindowsFolder.."\\omGOD DC\\Logins\\"..User..".oel", _TempFolder.."\\"..User..".zip", "pass");
Zip.Extract(_TempFolder.."\\"..User..".zip", {"User.ini"}, _TempFolder.."\\omGOD DC\\"..User, true, true, "pass", ZIP_OVERWRITE_ALWAYS, nil);
ePass = INIFile.GetValue(_TempFolder.."\\omGOD DC\\"..User.."\\User.ini", "UserData", "pDesc");
dPass = Decrypt(ePass);
if Pass == dPass then
Zip.Extract(_TempFolder.."\\"..User..".zip", {"*.*"}, _TempFolder.."\\omGOD DC\\"..User, true, true, "pass", ZIP_OVERWRITE_ALWAYS, nil);
ldTable = {}
ldTable.Correct = true;
ldTable.uPic = _TempFolder.."\\omGOD DC\\"..User.."uPic.img";
ldTable.pDesc = INIFile.GetValue(_TempFolder.."\\omGOD DC\\"..User.."\\User.ini", "UserData", "pDesc");
ldTable.uName = User;
return ldTable
else
ldTable = {}
ldTable.Correct = false;
return ldTable
end
else
ldTable = {}
ldTable.Correct = false;
return ldTable
end
end

screwed over
03-25-2008, 08:31 PM
thanks for the suggestions. I went with RizlaUK's suggestion and it works brilliantly now. Can't believe i forgot that bit, *hits self*.

thanks again, much apreciation.
J.D.