Problem with timer, infinite loop and json file

Hello,

When I build a simple timer with only one iterations, there is a bug with the program.

I work with the zerobrane ide.

I open (already exist) a empty new file called “data.txt” at the main.lua directory, and write “test” inside, then close.

But the program restart the code infinitly ( print event.count = 1 each three second ).

What to do ??

Thanks.

local function update(event)   print(event.count) // print "1" each time, so the program restart the code infinitly   local file=io.open(system.pathForFile("data.txt",system.ResourceDirectory),"w")   file:write(json.encode("test"))   io.close(file)   file=nil   end timer.performWithDelay(3000,update,1)

The code you have posted will only execute once so you must have other code running that is calling (update).

Make sure it really is 

timer.performWithDelay(3000,update,1)

 and not 

timer.performWithDelay(3000,update,-1)

Hello,

no it’s write “one” for the loop. I try with 2 or 3 it’s the same.

And there are only one update function .

The code you have posted will only execute once so you must have other code running that is calling (update).

Make sure it really is 

timer.performWithDelay(3000,update,1)

 and not 

timer.performWithDelay(3000,update,-1)

Hello,

no it’s write “one” for the loop. I try with 2 or 3 it’s the same.

And there are only one update function .