A question on table use

I have a table of 8 entries. I’m trying to add a ninth one and I get an index error in the runtime code. Here is the table definition that works:

`Week <- {
Sun = false,
Mon = false,
Tue = false,
Wed = false,
Thu = false,
Fri = false,
Sat = false,
Dur = 0

}`

I can use/set/read all the values into table correctly. However, if I add another entry in the definition for example:
`Week <- {
Sun = false,
Mon = false,
Tue = false,
Wed = false,
Thu = false,
Fri = false,
Sat = false,
Dur = 0,
Num = 0

}`

I get this error:

ERROR: the index 'Num' does not exist 2014-08-14 18:21:10 UTC-7 [Agent] ERROR: at Get_days:355 2014-08-14 18:21:10 UTC-7 [Agent] ERROR: from main:440

on this line of code:

StatusTable.DaysSet = Week.Num;

This line works:

StatusTable.Duration = Week.Dur;

Any clues as to why it’s not working? It looks like to me I can only have 8 entries in a table. I tried sticking Num before Dur and get the same error.

Thanks!

The
tags were added in the cut and paste and not part of the code.

mysterious. I copied your code but used server.log instead of the specific code you have.

I added it to the end of my agent code and it runs just fine.

`Week <- {Sun = false,
Mon = false,
Tue = false,
Wed = false,
Thu = false,
Fri = false,
Sat = false,
Dur = 0,
Num = 1

}

server.log( Week.Num);

server.log( Week.Dur);

`

it puts out
1
0

just as one would expect.

It’s hard to say what’s happening without seeing the whole code. (To stop odd tags appearing in code snippets, put your code in tags.)

Peter

Well it’s really weird. I have a table declared ahead of this one where I can add values and call them in the code. The interesting thing to note is I walk through the Week table and send it to the server log, but it never prints the Num value. So it’s not getting set…

foreach(idx,val in Week){
server.log(Week[idx]);
StatusTable.Duration = Week.Dur;
StatusTable.Dummy = Week.Dur;
}

The code is over 450 line which might be a bit much to post.

I worked it out. I have the Weeks table stored on the server. As I added a new value to the table, this index/value was not stored on the server, as I try to restore the server at the beginning. I need to work on a fix for future code, but right now I forced a new table save. Then made a change to the code to get the data, which is now the right size from the server and fixed!!! Thanks for the help in looking and trying the snippets.