Sign in to follow this  
Followers 0
Trunkles

Getting the bits of a structure

6 posts in this topic

Here is a small bit of code.

Local $tTime, $d, $m, $y, $h, $m, $s

$tTime = _Date_Time_GetSystemTime()

$d = $tTime.Day

$m = $tTime.Month

$y = $tTime.Year

$h = $tTime.Hour

$m = $tTime.Minute

Am I accessing the structure returned by the function correctly? I couldn't find anything in the help file that explains structures.

Share this post


Link to post
Share on other sites



Have you run the example code in the help file? It shows you how to output that time to a string, and from there it wouldn't be hard to split it up how you would like to see it. You can also use the other _Date_Time* functions to help you get it into simply a date string and simply a time string.

Local $dt_SystemTime = _Date_Time_GetSystemTime()
Local $dt_DateString = _Date_Time_SystemTimeToDateStr($dt_SystemTime)
Local $dt_TimeString = _Date_Time_SystemTimeToTimeStr($dt_SystemTime)

The above code is untested by me, but I wrote that pretty simply from the example in the help file so I am pretty sure it would work. I would recommend you look in the help file before asking questions here. I realize you didn't understand the help file on that function, but did you run the example?

Also if you want it further broken down into the Hours Minutes Seconds and such then you will need to split the string.

I just thought of a few other things in the help file that would actually help you and might save you some time. Look up "macros". I'm thinking those will be better suited to what you're looking for instead of a call to the WinAPI.

I hope I have helped some,

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

Indeed I have, _Date_Time_SystemTimeToDateStr() is superb for the task I'm doing, provided it's for use in the USA. Unfortunately, that function formats a date in MM/DD format which is not recogised here. So, rather than splitting the formatted string, I did the following,

Local $tTime, $TimeStamp, $d, $m, $y, $h, $m, $s

$tTime = _Date_Time_GetSystemTime()

$d = $tTime.Day

$m = $tTime.Month

$y = $tTime.Year

$h = $tTime.Hour

$m = $tTime.Minute

$TimeStamp = " - " & String($d) & "/" & String($m) & "/" & String($y) & " "

$TimeStamp &= String($h) & ":" & String($m) & " " & $UserInits & " "

which doesn't work. $UserInits is generated elsewhere.

According to the help file, _Date_Time_SystemTimeToDateStr() returns a $tagSYSTEMTIME which, according to the help file, is defined as Global Const $tagSYSTEMTIME = "short Year;short Month;short Dow;short Day;short Hour;short Minute;short Second;short MSeconds. What I want to do is get at the elements of the $tagSYSTEMTIME so that I can build the $TimeStamp string how I want it.

Share this post


Link to post
Share on other sites

Did you read about the macros?


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

AutoIt needs a new macro @IDIOT that evaluated to "Trunkles". >_<

Thank you, it works perfectly now. :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0