mIRC Home    About    Download    Register    News    Help

Print Thread
#201412 27/06/08 08:50 PM
Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
I was wondering if it's possible for me to put 2 data value in each it's data value with a seperater. I.E.

itemname1 data1a|data1b data2a|data2b

I'm looking at tracking channels with join ctime that a user has been on. I.E.

sam appleroom|98732457 banaroom|0928734

Then for each data value I can extract with gettok 1 or -1 to 124 which is |.

I just realized that if I do it this way, I can't just do a simple $addtok the the next time the user joins a channel they have already been on. Forst I'd have to find the channel in the data for the user, then replace it with the new data or add it to the end, this way I'd know which prior channel they were on, in backwards order.


I registered; you should too.
Joined: Aug 2003
Posts: 144
M
Vogon poet
Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
Hi.
I am not sure what you mean but check this...

Code:
alias test {
  hadd -m test sam appleroom|98732457
  echo -s $hget(test,sam)
  hadd -m test sam $hget(teste,sam) banaroom|0928734
  echo -s The entire value -> $hget(test,sam)
  var %Firts $gettok( $hget(test,sam), 1, 32)
  echo -s The firts data --> data1a = $gettok( %Firts, 1, 124) data1b = $gettok( %Firts, 2, 124)
  var %Second $gettok( $hget(test,sam), 2, 32)
  echo -s The second data --> data2a = $gettok( %Second, 1, 124) data2b = $gettok( %Second, 2, 124)
  hfree test
}


hope i was helpfully... Good luck

Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
Here's what I came up with:

This goes in the on JOIN:

Code:
  set %a $hget(userchans,$nick)
  if ($chan isin %a) {
    set %userchans $reptok(%a,$chan $+ $chr(124) $+ *,$chan $+ $chr(124) $+ $ctime,1,32)
  }
  else set %userchans $addtok(%a,$chan $+ $chr(124) $+ $ctime,32)
  ;echo -s userchans: %userchans
  .hadd userchans $nick %userchans


This goes in the output area:

Code:
  set %a $hget(userchans,%nick)
  set %b 1
  set %c $numtok(%a,32)
  while (%b <= %c) {
    set %d $gettok(%a,%b,32).data
    set %e $hget(channumnames,$gettok(%d,1,124))
    set %f $duration($calc($ctime - $gettok(%d,-1,124)))
    set %g $addtok(%g,%e $+ $chr(124) $+ %f,32)
    inc %b
  }
  echo 4 -s %nick %c : %g


If anyone has any code suggestions, I'm all ears (eyes).


I registered; you should too.
Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
This line doesn't seem to be working right:

set %userchans $reptok(%a,$+($chan $+ *),$+($chan $+ $chr(124) $+ $ctime),1,32)

When a user joins the channel with just the channel in there data and not the $ctime, it's not adding the $time to the channel names for their data. If a user joins the channel and they do have the $ctime attached to the channel name, it's not updating the channel $ctime (second half of the data value).

channelname|$ctime


I registered; you should too.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You're combining two different methods of using the $+ concatenation method. Each one by itself would work, but combining them does not

Try set %userchans $reptok(%a,$+(%chan,*),$+($chan,$chr(124),$ctime),1,32)

Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
Originally Posted By: RusselB
You're combining two different methods of using the $+ concatenation method. Each one by itself would work, but combining them does not

Try set %userchans $reptok(%a,$+(%chan,*),$+($chan,$chr(124),$ctime),1,32)


I tried that, I even pasted your line exactly, and it still didn't work. It's not updating the $ctime. Also, it's not adding the $ctime to data value channels that don't have it. This is telling me that there's still something wrong with the search string with the wildcard, as the original %a is still the same.

Yep, it's the wildstar on the search string. When I remove that and just put $chan for the search string, then on the data values that only have a channel name, it'll add the $ctime to those. So what's the deal with the wildcard and why won't it work correctly?


I registered; you should too.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Of course the %a is going to be the same before and after the code has run, since you aren't altering %a. The code says to search for the channel followed by any number of characters (btw, I noticed that I accidentally used %chan not $chan for the search parameter), then if the channel is found in %a concatenate the channel name with the | character and the current time, then place that information into the variable %userchans.

Thus %userchans would contain the altered information, not %a

Also note that %a and %userchans will change for each run of the code, and if the channel name isn't found in %a then %userchans will get set to $null

Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
I noticed the %chan vs. $chan too.

Here's what I ended up doing to get it to work:

set %z $wildtok(%a,$chan $+ *,1,32)
set %userchans $reptok(%a,%z,$+($chan,$chr(124),$ctime),0,32)


I registered; you should too.
Joined: Aug 2003
Posts: 144
M
Vogon poet
Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
Well you can always use the $eval identifiers to evaluate 2 or 3 times the values...

like:

set %userchans $eval( $reptok(%a,$+($chan $+ *),$+($chan $+ $chr(124) $+ $ctime),1,32), 2)

the last numbers belong to the $eval method that will in this case evaluate 2 times de value and get the proper data...

hope this had help...

Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
Originally Posted By: Miguel_A
Well you can always use the $eval identifiers to evaluate 2 or 3 times the values...

like:

set %userchans $eval( $reptok(%a,$+($chan $+ *),$+($chan $+ $chr(124) $+ $ctime),1,32), 2)

the last numbers belong to the $eval method that will in this case evaluate 2 times de value and get the proper data...

hope this had help...


What was happening is the $+(%chan,*) in the $reptok wasn't working and detecting the channel in channel or channel|23409865 and either adding the $ctime to channel or updating the $ctime in channel|23409865. The only way I could get it to work was to use the seperate wildcard search to find the exact token to replace.


I registered; you should too.
Joined: Aug 2003
Posts: 144
M
Vogon poet
Offline
Vogon poet
M
Joined: Aug 2003
Posts: 144
i think you can´t use the a wild search... you need to specif a token search. Don´t use the * on the token search...

Last edited by Miguel_A; 28/06/08 10:46 PM.
Joined: May 2008
Posts: 329
A
AWEstun Offline OP
Fjord artisan
OP Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
Originally Posted By: Miguel_A
i think you can´t use the a wild search... you need to specif a token search. Don´t use the * on the token search...


That's probably why I coud only get it to work with $chan, to seach for channel's that didn't have a time. (Originally the time wasn't saved with the channel.)

Then I found out that the following worked:

set %z $wildtok(%a,$chan $+ *,1,32)
set %userchans $reptok(%a,%z,$+($chan,$chr(124),$ctime),0,32)

I just tried your $eval way and that didn't work, so like you said, you can't use a wildcard in the search.


I registered; you should too.

Link Copied to Clipboard