mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
#142551 18/02/06 04:00 PM
Joined: Oct 2003
Posts: 9
S
Suntop Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Oct 2003
Posts: 9
How do I make the timestamp output work with milliseconds?

I was told I have to make a script to make that work,
but how should i make that work with the default timestamp output
without messing it up?

and how do i even make mirc count milliseconds?
The only thing I know of that uses milliseconds is timers,
but I cant get the timestamp to work with that...or?

Thanx in advance smile


--==> Wizard Suntop <==--
Joined: Dec 2002
Posts: 28
P
Ameglian cow
Offline
Ameglian cow
P
Joined: Dec 2002
Posts: 28
mIRC's timestamp feature uses the formatting parameters from $asctime() identifier (/help $asctime), and there are no identifiers for milliseconds. Actually, there are no identifiers that can return the current time in milliseconds.

Ping and timers can use milliseconds only because they compute the DIFFERENCE between two moments in time expressed in milliseconds - actually, in "ticks" elapsed since the computer was started. But $ticks in itself has no meaning, as it didn't have a precise reference point; only difference between two values of $ticks is useful, to accurately determine the duration of a process.

Out of curiosity, what do you need such a high precision timestamping for? How is it useful to you, considering how many other factors can influence the delay of messages appearing on your screen, like lag and even processor load that slows down refreshing mIRC windows?

Joined: Oct 2003
Posts: 9
S
Suntop Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Oct 2003
Posts: 9
Quote:
mIRC's timestamp feature uses the formatting parameters from $asctime() identifier (/help $asctime), and there are no identifiers for milliseconds. Actually, there are no identifiers that can return the current time in milliseconds.


I know, thats why I asked in the first place..

Quote:
Ping and timers can use milliseconds only because they compute the DIFFERENCE between two moments in time expressed in milliseconds - actually, in "ticks" elapsed since the computer was started. But $ticks in itself has no meaning, as it didn't have a precise reference point; only difference between two values of $ticks is useful, to accurately determine the duration of a process.


So how can i make a script convert this to milliseconds, and how
can I make it replace the current $timestamp value without making
the settings in options overwrite the script?
..as well as to replace the values in all windows.. confused

Quote:
Out of curiosity, what do you need such a high precision timestamping for? How is it useful to you, considering how many other factors can influence the delay of messages appearing on your screen, like lag and even processor load that slows down refreshing mIRC windows?


It's for testing perposes..
I need the exact output time in milliseconds for several tasks i'm trying to perform..
and it will make fixing some of my scripts alot easier as well..

And I'm testing this on a private network, where lag and proccessor load isnt much of
an issue wink


--==> Wizard Suntop <==--
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
pre mirc6.17
Code:
;usage /ctimems : well revaluate the the offset values used to produce the $identifier results (2 second delay during this processing)
;usage $ctimems : returns $ctime and 3 digit decimal place being miliseconds, (2 second delay if no /ctimems call is made prior to this $identifier being used)
alias ctimems {
  if (!$var(%milliseconds.ticks,0) || !$var(%milliseconds.ctime,0) || (!$isid)) {
    var %ctime = $calc($ctime + 1)
    while (%ctime &gt;= $ctime) { }
    set -u1000000000 %milliseconds.ticks $calc($ticks - 1000)
    set -u1000000000 %milliseconds.ctime $calc($ctime - 1)
  }
  return $left($calc(%milliseconds.ctime + (($ticks - %milliseconds.ticks) / 1000) + .0001),-1)
}


mirc 6.17 only
Code:
;usage /ctimems : well revaluate the the offset values used to produce the $identifier results (2 second delay during this processing)
;usage $ctimems : returns $ctime and 3 digit decimal place being miliseconds, (2 second delay if no /ctimems call is made prior to this $identifier being used)
alias ctimems {
  if (!$var(%milliseconds.ticks,0) || !$var(%milliseconds.ctime,0) || (!$isid)) {
    var %ctime = $calc($ctime + 1)
    while (%ctime &gt;= $ctime) { }
    set -e %milliseconds.ticks $calc($ticks - 1000)
    set -e %milliseconds.ctime $calc($ctime - 1)
  }
  return $left($calc(%milliseconds.ctime + (($ticks - %milliseconds.ticks) / 1000) + .0001),-1)
}


* this was old code i wrote some time back , yell out if its not working right.

Joined: Oct 2003
Posts: 9
S
Suntop Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Oct 2003
Posts: 9
Thanx, this works the way i want if i implement this:
Code:
alias tpms { return $right($ctimems,3) }


but the main issue is still: how to get this to work in every window,
as a replacement of the actual $timestamp value ..without getting the
actual timestamp value in options to overrun it.. :-/


--==> Wizard Suntop <==--
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
unfortunetly the optiosn timestamp value doesnt allow u to insert identifiers like $x in else i would have said rename the alias to x and insert $x, maybve this should be a feature suggestion for the future who knows.

i wacked this together for you

Code:
alias ms.timestampfmt {
  var %ctime = $calc($ctime + 1)
  while (%ctime &gt;= $ctime) { }
  set -u1000000000 %ms.timestampfmt.fix $calc($ticks % 1000)
  .timer.ms.timestampfmt.fix -imo 0 15 ms.timestampfmt.fix
}
alias ms.timestampfmt.fix {
  var %timestampfmt = $timestampfmt
  if ($pos(%timestampfmt,s.,1)) {
    var %pos = $v1
    if ($mid(%timestampfmt,$calc(%pos + 2),3) isnum) {
      .timestamp -f $+($left(%timestampfmt,%pos),.,$right($calc($ticks - %ms.timestampfmt.fix),3),$mid(%timestampfmt,$calc(%pos + 5)))
    }
  }
}


First run /MS.TIMESTAMPFMT and it well start it off, it well have that 1 to 2 second delay anytime you run it
After that you well notice no change, unless you go into the timestamp format and insert ".000" (actually fullstop and any 3 numbers), ex [HH:nn:ss] to [HH:nn:ss.123]
Next time the timestamp is displayed the 3 digits are adjusting to the ms, im actually going in and reseting the timestamp 67 or so times a second ( /me is a resource hog! )

* now becuase this is done on a timer, if you are doing your own large looping (aka mirc freeze) then the timer doesnt get a chance to go off, thus the ms value well not update, so if your got a /echo -t in your loop the ms well jam, only way to fix that is to call MS.TEMPSTAMPFMT.FIX from inside your loop. This however is not major in my opion as from what i gather your after getting accurate time stamps on channels etc.

* again if u have mirc6.17 you can replace the -u1000000000 with a -e

--- edit ---
Calling out to REGEXERS!

Actually to any good regexer out there it would be nice if you could do a regsub on it, and thus reduce my code over head replacing all my ifs etc, and it would also allow replacing of more than one s.000 value
What i think is needed is to locate in $timestampfmt any occurance of s.### (# being a digit) and replace it with $+(s.,$right($calc($ticks - %ms.timestampfmt.fix),3)), Maybe also only set the timestamp if at least one was found, since im sure its resource hoggy to keep setting it if its not changed smile
Maybe along the lines of....
Code:
alias ms.timestampfmt.fix {
  var %timestampfmt = $timestampfmt 
  if ($regsub(%timestampfmt,[color:blue]&lt;re&gt;[/color],$+(s.,$right($calc($ticks - %ms.timestampfmt.fix),3)),%timestampfmt)) { timestamp -f %timestampfmt }
}


<re> to match s.###

Last edited by DaveC; 19/02/06 12:53 AM.
Joined: Oct 2003
Posts: 9
S
Suntop Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Oct 2003
Posts: 9
First.. i'm using mIRC 6.16
Will upgrade to 6.17 after a while, when more people have
tested it, and possible bugfixes has been released =)


And your code dont work...the actual replacement of the timestamp.

And I was wondering..is it easier to make hundreds?
(not sure what thats called)
like for every second, 0-99 is counted..
That is enough actually for what i need it for..
And both types would be nice to have the code of...
i might not be needing both, but would be nice to learn them anyway =)


--==> Wizard Suntop <==--
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
And your code dont work...the actual replacement of the timestamp.


You mean YOU cant get it to work, not it doesnt work. Becuase im using exactly that code right now.

And no hundreds would take an extra mids to get the value, and it would only be cutting the last digit off.

Regardless, rather than say "it dont work" , what part of my code are you having trouble with?

Did you start it using /ms.timestampfmt
Did the timer start (check using /timer)
Is there a s.000 in the timestamp format itself?

Joined: Oct 2003
Posts: 9
S
Suntop Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
S
Joined: Oct 2003
Posts: 9
Quote:
You mean YOU cant get it to work, not it doesnt work. Becuase im using exactly that code right now.

I tested it on mirc 6.16 without any other scripts
(except for one small one that simply shows help for uno (a script game of course))

Quote:
Regardless, rather than say "it dont work" ,
what part of my code are you having trouble with?

The replacement of the actual timestamp in options.
I did exactly as you said, went to options and replaced the
current value with [HH:nn:ss.000]
(even tried .123 to see if that helped)
but the timestamp simply didnt update..
or it DID display HH:nn:ss right..but showing only: .000
(or .123) repeatedly.
..so in other words...the milliseconds didnt update AT ALL..

Quote:
Did you start it using /ms.timestampfmt
Did the timer start (check using /timer)
Is there a s.000 in the timestamp format itself?

yes to all that :-)
Everything seemed to work, but as i said, the actual update
of the milliseconds never took place, and simply echoed what i typed in options..


--==> Wizard Suntop <==--
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
alias ms.timestampfmt {
  var %ctime = $calc($ctime + 1)
  while (%ctime &gt;= $ctime) { }
  set -u1000000000 %ms.timestampfmt.fix $calc($ticks % 1000)
  .timer.ms.timestampfmt.fix -imo 0 15 ms.timestampfmt.fix
}
alias ms.timestampfmt.fix {
  ///echo -s Stage 1/3
  var %timestampfmt = $timestampfmt
  if ($pos(%timestampfmt,s.,1)) {
    var %pos = $v1
    ///echo -s Stage 2/3 : %pos
    if ($mid(%timestampfmt,$calc(%pos + 2),3) isnum) {
      .timestamp -f $+($left(%timestampfmt,%pos),.,$right($calc($ticks - %ms.timestampfmt.fix),3),$mid(%timestampfmt,$calc(%pos + 5)))
      ///echo -s Stage 3/3 : $timestampfmt ********************************************************************************************************************
    }
  }
}


try that then and track what it gets to stage 1 2 or 3
PS: its gonna flood the status window like hell!

Joined: Dec 2002
Posts: 29
H
Ameglian cow
Offline
Ameglian cow
H
Joined: Dec 2002
Posts: 29
alias ms.timestampfmt.fix {

var %timestampfmt = $timestampfmt

if ($regsub(%timestampfmt,<re>,$+(s.,$right($calc($ticks - %ms.timestampfmt.fix),3)),%timestampfmt)) { timestamp -f %timestampfmt }

}

Code:
\d{2}:\d{2}:\d{2}.\d{3}

this will match ##:##:##.###

but it sounds like you want
Code:
\w{2}:\w{2}:\w{2}.\d{3}

this will match !!:!!:!!.### where ! is anything a-z,A-Z,0-9

alternatively, you could have
Code:
[A-Z]:[a-z]:[a-z].\d{3}

this will only match AA:aa:aa.### where AA is upper, and aa are lower, letters only

I'm not sure what exactly you require, and there may be a better expression to use, I've never really played with regex before, but I did test these to confirm they match how I stated.

hope this helps,

HobophobE

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I needed a regsub that would find s.000 through to s.999 aka s.### where # is a digit.

PS: . (dot) has a special meaning in a regsub.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
To find s.000 to s.999 you would use a regex like this:

/s\.\d{3,3}/

- Literal 's'
- Literal '.'
- Exactly 3 digits (0-9)
* Case sensitive

This would NOT match s.0 or S.000 . It will match s.183 s.724 s.025 etc. anywhere in the string.

-genius_at_work

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Thanks man, from that i got this....

Code:
alias ms.timestampfmt.fix {
  var %timestampfmt = $timestampfmt , %re = /s\.\d{3,3}/ 
  if ($regsub(%timestampfmt,%re,$+(s.,$right($calc($ticks - %ms.timestampfmt.fix),3)),%timestampfmt)) { .timestamp -f %timestampfmt }
}


however in a time stamp such as [HH:nn:ss.123 s.123] only the first instance of s.123 is updating.

Am I missing some switch on the regex to do all matches (that i dont know about)?

/me looks at feet shucks them around and wishes he had more time to waste learning regex, but sleeping is ment to be important as well!

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
To have it replace all instances, you need to use the 'g' (global) switch in the regex match:

/s\.\d{3,3}/g

BTW, if you want to learn some regex (even just the basics) you should try http://www.regular-expressions.info .

-genius_at_work

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
most excellent dude.

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Actually, using {3,3} doesn't help at all for ensuring that there may only be 3 consecutive digits. All it ensures is that the regex engine will only match the first 3 consecutive digits, but it will not result in a failing match when there are more digits.

Observe:

//echo -a $regex(1234,/(\d{3,3})/) -> $regml(1)

echoes 1 -> 123, even though it is clear that you only wanted the regex to match in case there are only 3 consecutive digits, no more, no less. The thing is that the engine did only match 3 digits, which is shown by the regml, but it didn't make the regex match fail even with that extra 4th one.

If you want to enforce this regex to only match in case of 3 and no more, you need to use some kind of boundary check like for instance:

\d{3}(?!\d) -> makes sure that whatever comes after the 3 digits isn't a digit, but can be every other char or the end of the string.

\d{3}(?= |$) -> enforces that any sequence of 3 digits is followed by either a space or the end of the string.

...

Typing this post was a drag with one hand, as I had an accident yesterday and broke my shoulder. I need speech technology frown


Gone.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You are correct. In fact I was only trying to match the 3 digits. Other digits (if they happened to exist for some reason in this example) would remain unchanged as there is nothing for them to be replaced with.

Could this example have worked? (I'm not positive on how \b works)
/s\.\d{3,3}\b/g
Using the \b word border to make sure the digits ended at a space/end of line. Obviously that wouldn't work if someone did s.123hh:nn:ss (for whatever reason).

-genius_at_work

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Well its not often i get to say Fiberoptics is mistaken, but he is, I asked for it to replace any occurance of "s.###" # being a digit. I never speciified that there can not be a digit following it.
Its a simple search and replace, no care needing to be taken with surrounding info.
The usage was in a timer to replace "s.###" with a new "s.###" that represents the current ms in the timestamp. This allowing anyone to dynamicly set there time stamp to anything they like and any occurrance of a "s" followed by ".###" would imediately add the ms. Its the userrs choice if they want to put something silly like "[HH.ss.0001234567:mm:dd]" in there.

/me waits for the envertable come back as im proven wrong frown

Last edited by DaveC; 20/02/06 06:41 PM.
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Everything I stated was correct, but the mixup is that you think I was taking into account your code, while I wasn't. I only saw his regex and the explanation of the parameters, including what {3,3} does, which is the basis of my post. Note how my code examples strictly centered around showing how {N,N} really works, not necessarily a regex to apply to whatever situation you need it in. I don't even know what your code does, as I only skimmed this thread.

Many people using regex are tricked when they assume that {N,N} will mean the regex will fail to match cases where there are more than N consecutive occurences. I don't even know if g_at_work knew it already, but if he did, it still contains some good info for other people, as it's an extremely common pitfall for people relatively new at regex.


Gone.
Page 1 of 3 1 2 3

Link Copied to Clipboard