Hi,
i’m new in lua and Corona, usually coding in delphi or vb,
now i’m trying this simple structure that
must read form a multidimensional array
that rappresents numbers of a lottery: tutteleestrazioni( draws , rows, numbers),
i want to scan entire array, then i increment all 90 numbers, rita[1…90] when draw changes
and i set rita[numeroinesame]=0 for all numbers i find when scanning the array of draws.
I want to calculate delay of numbers so at the end of this code… out of the scanning
cycles i expect to fine delay of numbers in 90 elements of rita[1…90] … but…
it happens that all elements are set at maximum number possibile…like if
all 90 elements have have been only incremented and never set to zero…
Thing that make me crazy is that inside the ‘for – next’ cycle the printing of
rita[] that is there for debugging is correct like this:
2000 8 86 0
2000 8 10 0 and so on… rita[86] and rita[10] are set to 0 as i expect
but out of the loop all elements of rita[] are … 4681 … the numbers of loops
and so all the increments done… never set to zero ?!
Please i know i’m doing somthing wrong with lua… but can’t understand…
can someone help me ?
Here is the code
function puliscearrayrita() --calling this create rita
rita = { }
local pos
for pos=1,90 do
rita[pos] = 0
end
end
function incrementaritordoditutti() – this function increments values for all elements in rita
for contatore=1, 90 do
rita[contatore]=rita[contatore]+1
end
end
– begin to scan array of three elements where i have loaded all draws
– external loop is now done with 'WHILE INDICE <= conteggiorighe (that is max dimension of indice just
–to try… it was the same doing another for…next
function calcolaritardi()
local j,z,contatore,numeroinesame
indice=1
while indice <= conteggiorighe do
incrementaritordoditutti() – call function that increment all elements in rita
for j=1,12 do
for z=1,5 do
numeroinesame = tutteleestrazioni[indice][j][z] – numeroinesame is the number found, catching all numbers
rita[numeroinesame] = 0 – i set ritato zero…here this works as i see printing
print(indice…" “…j…” “…numeroinesame…” "…rita[numeroinesame])
end
end
indice=indice+1
end – endwhile
end --endfunction
–HERE I CALL this functions written before
puliscearrayrita() – chiama pulisce il vettore che tiene i ritardi
calcolaritardi() – chiama la funzione che calcola i ritardi
–HERE I SCAN RITA… and i expect to see different values that are incremented delay of
–numbers… that’s because when found, each number has been set to zero and incrementing starts
–again, instead i see all elements of RITA incremented at maximum value of 4681…
– maybe a problem with scope but rita{} is global… so what ?
…Scanning rita[…90]
local i
for i = 1, 90 do
print (rita[i]) – rita elements are all 4681… what do i do wrong ?
end
Thank you… Roberto
[import]uid: 107268 topic_id: 28411 reply_id: 328411[/import]
[import]uid: 52491 topic_id: 28411 reply_id: 114908[/import]