Weird behaviour with nested tables and log - 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: Weird behaviour with nested tables and log (/showthread.php?tid=2407) |
Weird behaviour with nested tables and log - mjaanes - 30.12.2019 I am going crazy.... Working on a scheduled script and running it manually to check it. The code below neither print AAAAAAAAAA nor BBBBBBBBBBBB. However, if I comment out line 19 (log('DDDDDDDDDDD')), everything is printed out fine. What am I missing? Thanks in advance for any good input Rgds Christian CODE: ---------- log('AAAAAAAAAAAAAAAAAAAAAAAAAAAA') tPresenceCheck = { {'Area1', 10 , '0/200/0' , {'21/4/19','24/4/19'}}, {'Area2', 15 , '5/200/0' , {'21/4/19','24/4/19','25/4/9'}} } log('BBBBBBBBBBBBBBBBBBBBBBBBBB') log(tPresenceCheck) log(#tPresenceCheck) for i=1,#tPresenceCheck do log('CCCCCCCCCCCCCCCCCCCCCC') tCurr = tPresenceCheck[i] log(tCurr) sArea = tCurr[1] log(sArea) log('DDDDDDDDDDDDDDDD') end RE: Weird behaviour with nested tables and log - Erwin van der Zwart - 30.12.2019 Hi, Not sure if it’s always needed but you are missing the step size of the for loop. for start, stop, step do, in your case for i=1,#tPresenceCheck, 1 do BR, Erwin RE: Weird behaviour with nested tables and log - admin - 30.12.2019 Step is optional, but it's better to use ipairs for loop. Do you have anything in error logs? RE: Weird behaviour with nested tables and log - mjaanes - 30.12.2019 (30.12.2019, 09:11)Erwin van der Zwart Wrote: Hi, Thx for the quick reply. LUA should default the step size to 1 if missing. Tried anyway to add ,1 but in vain. It is really odd. I can actually comment out any one of the four "log" statements inside the for-loop and things will work fine. Once all log statements are there, I do not get any AAAAAAAAA or BBBBBB. Is it something basic I am missing? Thx Rgds Christian RE: Weird behaviour with nested tables and log - admin - 30.12.2019 Try removing all spaces/tabs before statements in for loop. RE: Weird behaviour with nested tables and log - mjaanes - 30.12.2019 Here is another (simpler) example that is not working. The code below does not print the "AAAAAAAAAAAAAAA" (the first line statement). If I comment out the log statement in the inner for-loop, everything works fine. CODE: ----------------------------------------------------------------- log('AAAAAAAAAAAAAAAAAA') local pid = os.getpid() spid = ' (pid=' .. pid .. ')' log('STARTING SCRIPT ' .. _SCRIPTNAME .. spid) log('BBBBBBBBBBBBBBBBBBB') for i=1,2,1 do log( 'CCCCCCCCCCCCCCCCCC') for j=1,3,1 do log('DDDDDDDDDDDDDDDD') end end OUTPUT: ----------------------------------------------------------------- ZZTest 30.12.2019 12:04:03 * string: STARTING SCRIPT ZZTest (pid=5393) ZZTest 30.12.2019 12:04:03 * string: BBBBBBBBBBBBBBBBBBB ZZTest 30.12.2019 12:04:03 * string: CCCCCCCCCCCCCCCCCC ZZTest 30.12.2019 12:04:03 * string: DDDDDDDDDDDDDDDD ZZTest 30.12.2019 12:04:03 * string: DDDDDDDDDDDDDDDD ZZTest 30.12.2019 12:04:03 * string: DDDDDDDDDDDDDDDD ZZTest 30.12.2019 12:04:03 * string: CCCCCCCCCCCCCCCCCC ZZTest 30.12.2019 12:04:03 * string: DDDDDDDDDDDDDDDD ZZTest 30.12.2019 12:04:03 * string: DDDDDDDDDDDDDDDD ZZTest 30.12.2019 12:04:03 * string: DDDDDDDDDDDDDDDD RE: Weird behaviour with nested tables and log - Daniel - 30.12.2019 Check in LM log tab, it is there. RE: Weird behaviour with nested tables and log - mjaanes - 30.12.2019 (30.12.2019, 11:21)Daniel. Wrote: Check in LM log tab, it is there.Wow! Thanks so much. I was only looking at the log window which you can pop-up from the code editor. In this log-window, apparently not all logs are captured. Weird!, but good to know. HAPPY NEW YEAR Rgds Christian |