02-22-2022 01:35 AM
Hy all,
another banal question of mine. I want to show in diadem script the current Time with milliseconds. I found this function: call msgbox(RTT(time,"#hh:nn:ss,fff")). But if I run this, it always schows the milliseconds "000". I think it's all but impossible to hit every time the 0 milliseconds.
I also tried ApplicationTimebaseHighResolution = true, but there is the same result.
Did somebody know how I can get the right millisecond value from script?
thank you.
03-11-2022 08:41 AM
Hello MarioRindfleisch. Can you try to put in function #DD.DDDDDDDDDDDD and try to vary the numbers of Ds and point's location?.
03-11-2022 08:59 AM
Hi MarioRindfleisch,
VBS only supports time up to seconds, but no milliseconds.
Greetings
Walter
03-14-2022 02:27 AM
Hy Vazgen_H,
no that doesn't work. It alway show 1.DDD with different numbers of "D"s.
Someone else an idea?
03-14-2022 02:42 AM
Hy Walter,
thank you for your awnser. That sounds not so good :-(.
There's a diskription in the helpfile, how to show the Milliseconds:
"
Bestimmt die aktuelle Systemzeit. DIAdem übernimmt das im Betriebssystem eingestellte Format für die Zeitangabe.
Die Methode Time zeigt wie CurrTime die Uhrzeit an. Wenn Sie wie bei den Funktionen TTR und RTT auch das Datum in der Zeitangabe benötigen, fügen Sie CurrDate hinzu. Wenn Sie auch die Millisekunden anzeigen wollen, können Sie RTT(Time) verwenden, wobei die Funktion RTT dann nicht das aktuelle Datum anzeigt, sondern das Jahr in Abhängigkeit von der Variablen ApplicationTimebaseHighResolution ausgibt."
but it doesen't work.
i've tried the following:
ApplicationTimebaseHighResolution = true
LogFileWrite RTT(time,"#hh:nn:ss,fff")
ApplicationTimebaseHighResolution = false
an
ApplicationTimebaseHighResolution = true
LogFileWrite RTT(time)
ApplicationTimebaseHighResolution = false
If vbscript doesn't supports milliseconds, the helpfile makes no sense.
03-16-2022 04:33 AM
Hi MarioRindfleisch,
Yes, you are right. The help text is not that clear. VBS time does not support fractions of seconds, but DIAdem does. I have created an example which hopefully explains the difference.
dim oChn, oGroupChns, sTimeString
call Data.Root.Clear
set oGroupChns = Data.Root.ChannelGroups.Add("Temp").Channels
set oChn = oGroupChns.Add("Time", DataTypeChnDate)
oChn(1) = Now ' VBS time
oChn(2) = TTD(CurrDate & " " & CurrTime) ' the same but with DIAdem functions
oChn(3) = CreateTime(2022,3,12,10,11,12,123,456) ' DIAdem USI time supports fractions of seconds
sTimeString = "Now - type: VBDate: " & GetTimeFormated(oChn.oValues(1)) & vbCRLF & vbCRLF & _
"CurrDate/CurrTime - type: VBDate: " & GetTimeFormated(oChn.oValues(2)) & vbCRLF & vbCRLF & _
"CreateTime - type: USITimeDisp-Objekt: " & GetTimeFormated(oChn.oValues(3))
call msgbox(sTimeString)
call LogfileWrite(sTimeString)
sTimeString = "Values(x) returns the VBDate type: " & oChn.Values(3) & vbCRLF & vbCRLF & _
"dValues(x) returns the internal DIAdem real representation: " & oChn.dValues(3) & vbCRLF & vbCRLF & _
"oValues(x) returns the USITimeDisp object: " & GetTimeFormated(oChn.oValues(3)) & vbCRLF & vbCRLF & _
"RTT (Date/Time is internaly a double value): " & RTT(oChn.Values(3)) & vbCRLF & vbCRLF & _
"TTR (Date/Time-string to double value): " & TTR("12.03.2022 10:11:12.123")
call msgbox(sTimeString)
call LogfileWrite(sTimeString)
'-------------------------------------------------------------------------------
function GetTimeFormated(oTimeVal)
GetTimeFormated = str(oTimeVal.Day, "0dd") & "." & str(oTimeVal.Month, "0dd") & "." & str(oTimeVal.Year) & " " & _
str(oTimeVal.Hour, "0dd") & ":" & str(oTimeVal.Minute, "0dd") & ":" & str(oTimeVal.Second, "0dd") & "." & _
str(oTimeVal.Millisecond) & str(oTimeVal.Microsecond)
end function
The example is also attached.
Greetings
Walter