DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Diadem script get time with milliseconds

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.

0 Kudos
Message 1 of 6
(1,770 Views)

Hello MarioRindfleisch. Can you try to put in function #DD.DDDDDDDDDDDD and try to vary the numbers of Ds and point's location?.

0 Kudos
Message 2 of 6
(1,698 Views)

Hi MarioRindfleisch,

 

VBS only supports time up to seconds, but no milliseconds.

 

Greetings

Walter

0 Kudos
Message 3 of 6
(1,693 Views)

Hy Vazgen_H,

 

no that doesn't work. It alway show 1.DDD with different numbers of "D"s.

 

Someone else an idea?

0 Kudos
Message 4 of 6
(1,670 Views)

Hy Walter,

 

thank you for your awnser. That sounds not so good :-(.

There's a diskription in the helpfile, how to show the Milliseconds:

"

Methode: Time für VBS

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.

0 Kudos
Message 5 of 6
(1,658 Views)

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

Message 6 of 6
(1,643 Views)