Logic Machine Forum
Error in the console Error of register - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Error in the console Error of register (/showthread.php?tid=979)



Error in the console Error of register - Carlos Padilla - 06.09.2017

user-function-library 06.09.2017 11:09:30
Common functions:1: attempt to index global 'port' (a nil value)
stack traceback:
Common functions:1: in main chunk


does anyone know why I get this error when I execute the following command

a = { f1 = 10, f2 = 20 }





 for k,v in ipairs(a) do

 log(k,v)

 end



-- all passed arguments will appear in Logs module
log(a)




RE: Error in the console Error of register - admin - 06.09.2017

Check your common function library


RE: Error in the console Error of register - Erwin van der Zwart - 06.09.2017

Hi,

This is a non array structured table, so you should use this:

Code:
a = { f1 = 10, f2 = 20 }
for key,value in pairs(a) do
 log(key,value)
end

Check this for explanation of the difference:

The difference between ipairs and pairs

BR,

Erwin