IonicWind Software

Creative Basic => General Questions => Topic started by: Egil on June 25, 2017, 01:42:24 PM

Title: Problems retrieving UTC from system.
Post by: Egil on June 25, 2017, 01:42:24 PM
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


Title: Re: Problems retrieving UTC from system.
Post by: billhsln on June 25, 2017, 06:33:09 PM
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
Title: Re: Problems retrieving UTC from system.
Post by: GWS on June 25, 2017, 11:59:48 PM
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
Title: Re: Problems retrieving UTC from system.
Post by: Andy on June 26, 2017, 12:15:22 AM
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.
Title: Re: Problems retrieving UTC from system.
Post by: Egil on June 26, 2017, 02:33:32 AM
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
Title: Re: Problems retrieving UTC from system.
Post by: Egil on June 26, 2017, 10:48:12 AM
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


Title: Re: Problems retrieving UTC from system.
Post by: Andy on June 27, 2017, 12:46:26 AM
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.

:)
Title: Re: Problems retrieving UTC from system.
Post by: Egil on June 27, 2017, 02:25:36 AM
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