Array problem (index does not exist)

Started by MrAzzeroth, Mar 20, 2017, 07:34 PM

Previous topic - Next topic

MrAzzeroth

Hy all!

What is the problem in this?

local var= {};
..
var[tmp[rt_i]["id1"]] <- {};
var[tmp[rt_i]["id1"]][tmp[rt_i]["id2"]] <- GetValue();
The id1,id2 and the GetValue return with true value like 1,2..
And i get this error when i want to get the value ( var[1][1] )
<Error (the index '1' does not exist)>I read the FAQ the index _____ does not exist", but this doesnot help me
Please help, sorry for bad english.

jWeb

The same way:
local 1 = 76;Does not work.
Neither:
sometable.1 = 39;Or:
sometable.1 <- 39;Does not work either. Because index names cannot begin with a number.

That kind of behavior is achieved differently:
sometable.rawset(1, 39);
print(sometable.rawget(1));

MrAzzeroth

It's okay, but i want to create like this: var[1..100][1..x]
'cus, this need to query from database, and important the array length like:
var[1] length == 23
var[2] length == 26
..
want to increase while query
sorry bad english

vito

dunno what problems is, but there is just an example:
a <- {};
for(local i = 0; i < 100; i++){
local b = {};
for(local j = 0; j < 100; j++){
b.rawset(j, "i="+i+" j="+j);
}
::a.rawset(i, b);
}
print(::a[3][10]);
print(::a[69][33]);

MrAzzeroth