News:

  • September 23, 2026, 12:22:35 PM

Login with username, password and session length

Author Topic: Copying Date/Time variables  (Read 9111 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Copying Date/Time variables
« on: February 23, 2022, 03:53:09 PM »
I want to date stamp an event and I don't mind the timestamp being in the special DT register layout, but I can't find an expression that will take a DT as the source.   MOVE and MEMCOPY both don't like it.   I'd like to move to a range of MHR registers, so if I move the entire DT it will be 8 words, which is fine.

Is there an easier way than separate boxes MOVEing $Now.Year, $Now.Month, etc, one at a time?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Copying Date/Time variables
« Reply #1 on: February 23, 2022, 04:43:16 PM »
MEMCOPY SDT0 to MHR100 w/Count of 1 Source

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Copying Date/Time variables
« Reply #2 on: February 23, 2022, 04:45:28 PM »
And the Memory Layout utility mentioned in the MEMCOPY editor shows you exactly how it will be layed out in your MHR WORD memory (on DWORD boundaries):

Code: [Select]
"Date/Time Struct" Structure Memory Layout (2 total DWORDs in length, DWORD Offset 0..1)
+------++----------------------------------------------------------------------------------------------------------------------------------++
|      || Most Significant                                                                                               Least Significant ||
|      ++----------------------------------------------------------------------------------------------------------------------------------++
|      ||                                                              DWORD                                                               ||
|      ++----------------------------------------------------------------++----------------------------------------------------------------++
|      ||                             WORD 1                             ||                             WORD 0                             ||
|      ++-------------------------------++-------------------------------++-------------------------------++-------------------------------++
|      ||             BYTE 3            ||             BYTE 2            ||             BYTE 1            ||             BYTE 0            ||
|DWORD ++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++
|Offset||b31|b30|b29|b28|b27|b26|b25|b24||b23|b22|b21|b20|b19|b18|b17|b16||b15|b14|b13|b12|b11|b10| b9| b8|| b7| b6| b5| b4| b3| b2| b1| b0||
+------++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++---+---+---+---+---+---+---+---++
Note: Every Bit Field layout only shows the Field # (no name).  See the list of Bit Field Names listed by Field # at the end.

+------++----------------------------------------------------------------++-------------------------------++-------------------------------++
|    0 ||   2                         .Year                        UWORD ||   3         .Month      UBYTE ||   4          .Day       UBYTE ||
|      ||----------------------------------------------------------------++-------------------------------++-------------------------------++
|      ||   1                                                          .Date                                                        SDWORD ||
+------++-------------------------------++-------------------------------++-------------------------------++-------------------------------++
|    1 ||   6       .DayOfWeek    UBYTE ||   7         .Hour       UBYTE ||   8        .Minute      UBYTE ||   9        .Second      UBYTE ||
|      ||-------------------------------++-------------------------------++-------------------------------++-------------------------------++
|      ||   5                                                          .Time                                                        SDWORD ||
+------++----------------------------------------------------------------------------------------------------------------------------------++

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Copying Date/Time variables
« Reply #3 on: February 23, 2022, 04:48:47 PM »
So
MHR100:UB0 will be the .Day
MHR100:UB1 will be the .Month
MHR101:U will be the .Year
MHR102:UB0 will be the .Second
MHR102:UB1 will be the .Minute
MHR103:UB0 will be the .Hour
MHR103:UB1 will be the .DayOfWeek

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Copying Date/Time variables
« Reply #4 on: February 23, 2022, 04:56:28 PM »
OH, I see what I was doing.   It was telling me that the struct layout COULD be viewed in the UDT editor, and  I read it as COULDN'T (plus the part about the UDT configurator was off the side of the dialog), so I thought it was objecting to the use of a DT type variable.   I just needed to hit OK.

Sorry for the false alarm.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Copying Date/Time variables
« Reply #5 on: February 23, 2022, 05:06:45 PM »
OH, I see what I was doing.   It was telling me that the struct layout COULD be viewed in the UDT editor, and  I read it as COULDN'T (plus the part about the UDT configurator was off the side of the dialog), so I thought it was objecting to the use of a DT type variable.   I just needed to hit OK.

Sorry for the false alarm.

Yup - we stuck that "info" message in there to inform the user that they probably need to see the layout of their memory when doing a MEMCOPY of a structure to a raw memory block (or vice versa), rather than trying to figure it out by hand (not sure how they would know what the actual layout of a Designer structure would be without that tool).