I have used the definiton below several times in EB and IWB for retreiving UTC. But when trying the same with CB, I get an "Unknown Type" error in the line: def st:SYSTEMTIME.
Any suggestions for what I can do different???
Egil
DECLARE "kernel32.dll",GetSystemTime(st:SYSTEMTIME)
TYPE SYSTEMTIME
DEF wYear:WORD
DEF wMonth:WORD
DEF wDayOfWeek:WORD
DEF wDay:WORD
DEF wHour:WORD
DEF wMinute:WORD
DEF wSecond:WORD
DEF wMilliseconds:WORD
ENDTYPE
def st:SYSTEMTIME
My quickest suggestion would be to move the DECLARE to after the DEF.
Thinking that it needs to be defined before it can be used.
Bill
Hi Egil,
That's odd .. this works for me, and debug 'Build - Show Variables' is correct ..
' Creative Console skeleton ..
openconsole
cls
autodefine "off"
DECLARE "kernel32.dll",GetSystemTime(st:SYSTEMTIME)
TYPE SYSTEMTIME
DEF wYear:WORD
DEF wMonth:WORD
DEF wDayOfWeek:WORD
DEF wDay:WORD
DEF wHour:WORD
DEF wMinute:WORD
DEF wSecond:WORD
DEF wMilliseconds:WORD
ENDTYPE
def st:SYSTEMTIME
st.wminute = 46
stop
do:until inkey$<>""
closeconsole
end
Best wishes, :)
Graham
Egil,
I can confirm (and as you say) it works in IWB - just tried it.
As Graham has no problems with it, I wonder if there is something there that shouldn't be i.e. an unprintable character?
I have had this once or twice in IWB - and it drove me crazy.
Try actually re-typing the lines in a new file (not copy and paste) and see if you can then compile it.
Andy.
Thanks for trying, guys!
This is quite a mystery to me...
I have tried the code with all four versions of CB in my possession. But as soon as I try to define st as SYSTEMTIME I get an error, whithout actually calling the API function. Trying on a laptop gave the same result, even after typing all in by hand instead of copying. Drives me nuts!
Also tried Bill's suggestion, but the result was the same...
But since I most probably will convert the code to either IWB after trying out a few new ideas, I'll just put this routine aside for a while and go outside counting raindrops... Its really pouring down here today.
Egil
Decided to have one more try.
Did as Andy suggested. Deleted the type definition and typed it again. BINGO!
The code below is what I have struggled with all day, but now it works.
Egil
' UTCtime.cba
DECLARE "kernel32.dll",GetSystemTime(st:SYSTEMTIME)
TYPE SYSTEMTIME
DEF wYear:WORD
DEF wMonth:WORD
DEF wDayOfWeek:WORD
DEF wDay:WORD
DEF wHour:WORD
DEF wMinute:WORD
DEF wSecond:WORD
DEF wMilliseconds:WORD
ENDTYPE
DEF st:SYSTEMTIME
OPENCONSOLE
DEF hours,mins,secs:string
GetSystemTime(st)
hours = USING("0##",st.wHour)
mins = USING("0##",st.wMinute)
secs = USING("0##",st.wSecond)
PRINT "UTC time now: " + hours + mins + secs
PRINT
PRINT
PRINT "Press ESC to end"
do:until INKEY$ = CHR$(27)
CLOSECONSOLE
END
Egil,
Glad you got it working!
These are the things that can make you throw your computer out of the window, and start doubting your sanity.
I once had a flickering monitor at an office, spent days trying to find out what was wrong - it turned out it was that bit too close to another monitor!
As Sherlock Holmes was supposed to say, after eliminating all the other possibilities, what ever remains, no matter how implausible must be the answer.
:)
QuoteThese are the things that can make you throw your computer out of the window, and start doubting your sanity.
Use a shotgun next time. Solves the problem permanently... ;D
Egil