mIRC Homepage
Posted By: sparta $calc - 04/11/04 05:12 AM
i have this value: 05:27:59 yes its a time set.. how can i calc the time between that value and the curent time? :tongue: or is it any easyer way to do it? i working on a seen script, and need to get the time when the nick was last seen quitting.. :tongue: never dont this befor so all help is welcome, i have been writing all the parts it needs, only this part left..
Posted By: feud Re: $calc - 04/11/04 05:24 AM
while i'm sure it is possible to calculate the time difference given your data, it would be much easier to use $ctime and then subtract that from the current $ctime. use $duration($calc(%var - $ctime))
Posted By: Sigh Re: $calc - 04/11/04 10:25 AM
Since a time is being handled I'd go with $duration here: $duration($abs($calc($duration($time(HH:nn:ss)) - $duration(05:27:59))))

You can alter the format of $time() to measure the time until or the time since the specific time
Posted By: sparta Re: $calc - 04/11/04 06:49 PM
No i haver this value stored in a text file:

nick (ident@host) was last seen changing nick on to newnick 1099593370

but how would i go about to calc the right numbers? $read cant filter out the part where it says '1099593370' ?

echo $read(info.txt, s, mirc) wont do me any good.. cos
1: i never know what the line beggins with..
2: the address can contain a number..

and that would screw everything up :tongue:
Posted By: Adrenalin Re: $calc - 04/11/04 08:32 PM
You can use regex to get 1099593370 from "nick (ident@host) was last seen changing nick on to newnick 1099593370"

Code:
  var %reg = /.*(\d{10})/
  var %str = nick (ident@host) was last seen changing nick on to newnick 1099593371
  echo zz $regex(%str,%reg)
  echo zazibu $regml(1)
Posted By: sparta Re: $calc - 04/11/04 08:54 PM
the red line:
Code:
var %reg = /.*(\d{10})/
var %str = nick (ident@host) [color:red] was last seen changing nick on to newnick[/color]  1099593371 
echo zz $regex(%str,%reg)
echo zazibu $regml(1)

changes, so its not shure it looks like that, how ever the 1099593371will be at the end of all the line, the 1099593371 changes tho.. so im not shure how that line would work? :tongue:
Posted By: Adrenalin Re: $calc - 04/11/04 09:10 PM
For that regular expresion have matter only the last 10 digitals from end of the line..
So it must work fine with..

var %str = nick (ident@host) 1099593371
var %str = nick (ident@host) blalvla 1099593371
or just
var %str = 1099593371

Hope that help..
Posted By: sparta Re: $calc - 04/11/04 09:22 PM
nope.. i guess i just have to give up this.. been trying everything i can think about now, also the codes provided by you..
Posted By: sparta Re: $calc - 05/11/04 03:12 AM
couldent edit my old post so here we go..
Code:
on *:text:*:#:{
  if ($1 == $seentrigger) {
    var %x $read(" $+ $mircdirmap/seen.text $+ ", w,* $+ $2 $+ *)
    set %tmp.seen $readn
    ;if (%tmp.seen == 1) { goto next } <<-- will be working later if nick not seen..
    var %reg = /.*(\d{10})/
    var %str = $2 (ident@host) was last seen changing nick on to newnick 1099593371
  }
}

i cant get it to give the time in days/houers/minutes/seconds .. it only send it as '1099593371' , and i have been trying to calc that diffrent ways, still same result.. it gives the wrong value.. so im totaly stuck here.. somone that ether can point me to the right way.. or maybe even show me how its done? :tongue:
Posted By: Darwin_Koala Re: $calc - 05/11/04 05:14 AM
To get the last token, just use $0 to find the number of space delimited tokens (in $1- ).

Thus, the time figure will be [ $ $+ $0 ],
e.g. /var %timeString = [ $ $+ $0 ]

Because this works with "$1-", the way to make it work efficiently is:

alias GetLastToken {
return [ $ $+ $0 ]
}


and in your main script:

var %timeTicksString = $GetLastToken($read(<whatever your read command is>))


Cheers,

DK

p.s. untested.
Posted By: Adrenalin Re: $calc - 05/11/04 08:24 AM
Code:
on *:text:*:#:{
  if ($1 == $seentrigger) {
    var %x $read(" $+ $mircdirmap/seen.text $+ ", w,* $+ $2 $+ *)
    set %tmp.seen $readn
    ;if (%tmp.seen == 1) { goto next } &lt;&lt;-- will be working later if nick not seen..
    var %reg = /.*(\d{10})/
    var %str = $2 (ident@host) was last seen changing nick on to newnick 1099593371
    if ($regex(%str,%reg)) {
      var %stime = $regml(1)
      var %difference = $duration($calc($ctime - %stime))
      msg $chan Last seen: %difference ago
    }
    else {
      echo ERROR.. Can't find last seen time..
    }
  }
}


Try that ? Untested..
Posted By: Sigh Re: $calc - 05/11/04 08:51 AM
You're on the right track here but the actual syntax would be $ [ $+ [ $0 ] ] since [ $ $+ $0 ] simply joins $ and $0 to yield $$0 and evaluates that. However, when using $0 within a custom alias called as an identifier, it returns the number of parameters, so when using $myalias(words here) $0 would return 1 with $1 returning "words here"

I'd just use $gettok for this particular script:

on *:text:$($seentrigger *):#:{
if ($gettok($read($mircdirmap/seen.txt,s,$2),-1,32)) msg # $2 was last seen $duration($calc($ctime -$ifmatch)) ago
else msg # I have not seen $2
}
© mIRC Discussion Forums