lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



Hi guys, i have this structure and i am getting a strange result. 
could anyone explain me why ?

PAUTAS = {
  [0] = {
    ID_PAUTA  = "GUILLE",
    REQ_FILES = {
  [0] = {FILENAME = "0-FILE1", MD5 = "0-MD5-1"},
      [1] = {FILENAME = "0-FILE2", MD5 = "0-MD5-2"},
  }
  },
  [1] = {
    ID_PAUTA  = "LICH",
    REQ_FILES = {
  [0] = {FILENAME = "1-FILE1", MD5 = "1-MD5-1"},
      [1] = {FILENAME = "1-FILE2", MD5 = "1-MD5-2"},
      [2] = {FILENAME = "1-FILE3", MD5 = "1-MD5-3"},
  }
  },
}

for i, pauta in pairs(PAUTAS) do
  print (i.."> "..pauta.ID_PAUTA);
  for k, req_file in pairs(pauta.REQ_FILES) do
    print(k.."  > "..req_file.FILENAME.." ("..req_file.MD5..")")
  end
end


i supposed to get this result:

0> GUILLE
0  > 0-FILE1 (0-MD5-1)
1  > 0-FILE2 (0-MD5-2)
1> LICH
0  > 1-FILE1 (1-MD5-1)
1  > 1-FILE2 (1-MD5-2)
2  > 1-FILE3 (1-MD5-3)

---------- BUT INSTEAD OF THAT, I ALWAYS GET THIS SORT (SWAP BETWEEN 2,1)

0> GUILLE
0  > 0-FILE1 (0-MD5-1)
1  > 0-FILE2 (0-MD5-2)
1> LICH
0  > 1-FILE1 (1-MD5-1)
2  > 1-FILE3 (1-MD5-3)
1  > 1-FILE2 (1-MD5-2)


ANY IDEA ?

thanks







Windows Live™: Keep your life in sync. Check it out!