October 30, 2025, 04:10:30 PM

News:

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


TYPE question (Curiosity)

Started by billhsln, July 08, 2013, 09:55:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

I have noticed that the SYSTEMTIME is defined 3 slightly different ways.

(1)
Type SYSTEMTIME
   def wYear As word
   def wMonth As word
   def wDayOfWeek As word
   def wDay As word
   def wHour As word
   def wMinute As word
   def wSecond As word
   def wMilliseconds As word
EndType

(2)
type SYSTEMTIME,2
     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

(3)
TYPE SYSTEMTIME,2
   Word wMillisecondsec,wSecond,wMinute,wHour,wDay,wDayOfWeek,wMonth,wYear
ENDTYPE

What does Optional byte packing value of 2 do for us (comparing 1 to 2).  The order of the fields seems reversed between 2 and 3, but they are both used the same.  I would think that the fields would be reversed as in (wMillisecondsec = wYear, etc).  So, how can this work?

Thanks,
Bill
When all else fails, get a bigger hammer.

LarryMc

I've never seen a structure defined like 3 is and yes it does look backwards.

As  for packing.
Heres a pretty good discussion about it.
http://www.ionicwind.com/forums/index.php?topic=48.msg420#msg420
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

Thanks Larry, that did help and thinking back, I do remember having to do that kind of stuff to make programs run quicker.

I have switched one of my programs to use #2 instead of #3 and it comes back with the same date/time info (WEIRD!!!).

Bill
When all else fails, get a bigger hammer.

billhsln

Sample:

Using:

type SYSTEMTIME,2
   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

Output:

2013-01-25 13:03 2013-01-25 13:03 PSG6090_to_PSV0190.exe
2011-03-22 15:02 2011-03-22 15:02 HGL_Comma_Delimited.exe
2013-06-13 12:20 2013-06-13 12:20 Merge_Multi_Files.exe
2013-01-10 17:19 2013-01-10 17:19 SAR0010-SAG5037.EXE
2010-10-11 11:05 2010-10-11 11:05 SHQ0160_Split.EXE
2010-10-11 11:05 2010-10-11 11:05 SHQ0170_Split.EXE

Press any key to continue . . .

Using:

type systemtime,2
   word wMillisecondsec,wSecond,wMinute,wHour,wDay,wDayofWeek,wMonth,wYear
endtype

Output:

2013-01-25 13:03 2013-01-25 13:03 PSG6090_to_PSV0190.exe
2011-03-22 15:02 2011-03-22 15:02 HGL_Comma_Delimited.exe
2013-06-13 12:20 2013-06-13 12:20 Merge_Multi_Files.exe
2013-01-10 17:19 2013-01-10 17:19 SAR0010-SAG5037.EXE
2010-10-11 11:05 2010-10-11 11:05 SHQ0160_Split.EXE
2010-10-11 11:05 2010-10-11 11:05 SHQ0170_Split.EXE

Press any key to continue . . .

Really don't understand why they both come up with the exact same result for date and time.  Really weird.

Bill
When all else fails, get a bigger hammer.