This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Error in the console Error of register
#1
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)

Reply
#2
Check your common function library
Reply
#3
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
Reply


Forum Jump: