Hello All,

I have a hash table, with around 1000 items.
Each item has a data line, in the following format:

token1 $chr(9) token2 $chr(9) token3 $chr(9) token4 $chr(9) token5 $chr(9) token6 $chr(9)

Now I need to loop trough the table quite often, and replace a certain token, with a new word.

So:
token1 $chr(9) token2 $chr(9) token3 $chr(9) token4 $chr(9) Apple $chr(9) token6 $chr(9)
Becomes:
token1 $chr(9) token2 $chr(9) token3 $chr(9) token4 $chr(9) Melon $chr(9) token6 $chr(9)

Now, I use this code for that:
Code:
    var %cnt = 1
    var %ttl = $hget(table,0).item
    while (%cnt <= %ttl) {
      var %id = %cnt
      var %old-string = $hget(table,%id)
      var %old-token = $gettok(%old-string,5,9))
      var %new-token = Melon
      var %new-string = $puttok(%old-string,%new-token,5,9)

      hdel table %id
      hadd table %id %new-string
      inc %cnt
    }


Is this the most efficient way of doing this?
I've noticed, that when this replacement has to be done like 20 times, it doesn't run very smoothly, and it seems to 'forget' replace some...

Does anyone have suggestions for this?

Thanks a lot!