mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
In a hash table how do I go about counting the data in an item, so that I can perform a task on each piece of data.


I registered; you should too.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
What do you mean by 'counting' the data? You can perform any regular string actions on hash table data after you reference it using $hget or $hfind.

-genius_at_work

Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
Originally Posted By: genius_at_work
What do you mean by 'counting' the data? You can perform any regular string actions on hash table data after you reference it using $hget or $hfind.

-genius_at_work


Well lets say there are data (IP's) for an item name. Each item name has a different number of data. I want to perform a task or each one of those data, but how do I know how many data are there for each item name? For example:

itemname1 1234 2434 6234 6346
itemname2 3456
itemname3 6345 2344

How do I know how many times to run the task for each item name, by data count?


I registered; you should too.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You need to locate the hash item and then use the token identifiers to access each section of the data from that hash item.

Example:
Code:

var %data = $hget(hash1,item3)
echo -a number of tokens: $numtok(%data,32)
echo -a first token: $gettok(%data,1,32)
%data = $puttok(%data,ABCD,1,32)
echo -a new first token: $gettok(%data,1,32)
hadd hash1 item3 %data



Example:
Code:

var %c = 0, %cc = $hget(hash1,0).item
  while (%c < %cc) {
    inc %c
    var %item = $hget(hash1,%c).item
    var %data = $hget(hash1,%item)

    var %i = 0, %ii = $numtok(%data,32)
    while (%i < %ii) {
      inc %i
      echo -a Item: %item  Data %i $+ : $gettok(%data,%i,32)
    }
  }
}



untested


-genius_at_work

Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
Thanks. $numtok() is what I was looking for. Then from that the tokens can be accessed with $gettok().


I registered; you should too.

Link Copied to Clipboard