October 30, 2025, 12:56:40 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


How can I retrieve the System time?

Started by Egil, April 26, 2008, 11:45:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Egil

When trying to make a utility that will make me able to retrieve records containing geographical positions from two different radio decoding programs, reformat the records and finally sending them to a program that shows these positions on a map, I ran into a problem. Both decoding programs anmes the logfiles automaticly as February18.txt, April26.txt etc.
I thought this would be easy, by using filenames as logname = DATE$("MMMMdd") + ".txt" after defining logname as STRING. Both decoders use UTC for logging. But one of them use UTC and the other local time for setting filenames. Obviously I need to retrieve the system time to be able to use data from both at the same time.
By searching the internet, this was found: http://msdn2.microsoft.com/en-us/library/ms724950(VS.85).aspx.

Can anyone explain how to translate the example shown into EBasic?  I guess the method for doing so, also can be used for making other, similar translations.
Support Amateur Radio  -  Have a ham  for dinner!

REDEBOLT

Egil,

You can ignore the pre- and post- code.  They are just my personal wrappers.

Note that the EBasic code is very similar to the C code.

Quote$Main
autodefine "off"
openconsole
Declare IMPORT,ZeroMemory Alias RtlZeroMemory( Pointer pvoid,Int length),Int
'$Include "waitkey$.inc"
' WaitKey.inc
Declare IMPORT, Sleep(dwmillisecs As Int)
Sub WaitKey$(Opt raw=0 As Int),String
   String myinKey
   Do:Sleep(100):
      myinKey = InKey$(raw)
   Until myinKey<>""
   Return myinKey
End Sub
'
Int starttime,endtime,x
starttime = Timer

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' My translated code.
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$include "windows.inc"                                 ' #include <windows.h>
DECLARE CDECL EXTERN _printf(format as STRING,...)    ' #include <stdio.h>

'void main()
'{
    SYSTEMTIME st, lt
   
    _GetSystemTime(st)
    _GetLocalTime(lt)
   
    _printf("The system time is: %02d:%02d\n", st.wHour, st.wMinute)
    _printf(" The local time is: %02d:%02d\n", lt.wHour, lt.wMinute)
'}

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

label EndItHere
endtime = Timer
endtime -= starttime
If endtime < 0 Then
    endtime += 86400    ' Calculate time past midnight.
endif

Print
Print "Elapsed Time:"
Print endtime," secs."
Print
Print "Done..."
Print "Press any key to quit."
WaitKey$()
closeconsole
End
Regards,
Bob

Egil

Support Amateur Radio  -  Have a ham  for dinner!