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.
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
Thanks Bob!