Hi everyone,

I have build a structure wich counts the items for me. So i used the itemdedector from redpower2 that puls for every item that flows trough it. the computer count the signals and when he fineshed he will send it to a server. (MC 1.2.5)
[attachment=663:screen1.png]
The problem is, when the computer counts MORE than 101 items the output is weird.
[attachment=664:screen2.png]

Can anyone tell me what I do wrong?
Here is my code:
Wrong code!

Edit:
here is the real code
Spoiler
serverID = 11
ctd = 10
wlan = "top"

function connect()
    --print("connect")
    rednet.send(serverID, "HERE")
    a,b = rednet.receive(ctd)
    if(b == "YOU") then
        return true
    else
        return false
    end
end

function sendCount(count)
    while not connect() do
        --print("wait4connection")
    end
    --print("sendCount")
    rednet.send(serverID, tostring(count))
    a,b = rednet.receive(ctd)
    if(b == "OK") then
        return true
    else
        return false
    end
end

function count()
    
    while true do
        x = false
        rs.setOutput("front", false)        
        --print("start Event I")
        os.pullEvent("redstone")
        counter = 1
        os.startTimer("20")
        --print("start Event II")
        while true do
            a,b = os.pullEvent()
            if(a == "redstone") then
                if(x) then
                    os.startTimer("20")
                    counter = counter + 1
                    x = false
                else
                    x = true
                end
            elseif(a == "timer") then
                rednet.open(wlan)
                if(sendCount(counter)) then
                    --print("done")
                else
                    --print("error: sc.1")
                end
                rednet.close(wlan)
                break
            else
                --print("error: e.2")
            end
        end
    end
end

i found out that every count starts a new timer. so i have after 101 counted items 101 timers running. BUT i onyl need 1.
give it a way to reset the first timer? or what can i do that the program send the counted items, after 20 ticks after the last item?