problem returning tables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • screwed over
    Forum Member
    • Apr 2007
    • 176

    problem returning tables

    I am having some problem with one of my functions:
    Code:
    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
    Indigo Rose Customer
    • Aug 2003
    • 2498

    #2
    Is this a function defined somewhere else? "dPass = Decrypt(ePass);"

    Comment

    • screwed over
      Forum Member
      • Apr 2007
      • 176

      #3
      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.

      Comment

      • Desmond
        Indigo Rose Staff Member
        • Jul 2003
        • 710

        #4
        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:

        Code:
        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.

        Comment

        • RizlaUK
          Indigo Rose Customer
          • May 2006
          • 5552

          #5
          this should fix it:

          Code:
          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
          Embrace change in your life, you never know, it could all work out for the best

          Comment

          • screwed over
            Forum Member
            • Apr 2007
            • 176

            #6
            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.

            Comment

            Working...
            X