# < SOLVED> I need some help to Autoit code

## Recommended Posts

Hi all AutoIt users

I hope someone can help me to convert from one of this two examples Delphi or C + + to AutoIt code.

The first example is from Delphi:

day = (520161244 shr 24) and 256;

month = (520161244 shr 16) and 256;

year = 520161244 and 65535;

the Same, written in C + + Would be:

day = (520161244>> 24) & 256;

month = (520161244>> 16) & 256;

year = 520161244 & 65535;

Does Autoit supports bytes shift operations?

Edited by Borje

##### Share on other sites

Hi, Borje. AutoIT does indeed support shifting. Check out BitShift in the help file.

√-1 2^3 ∑ π, and it was delicious!

##### Share on other sites

Thanks JLogan3o13

##### Share on other sites

Borje, I think it would be best if you try explaining a little more about what you're trying to accomplish. What is your end goal?

√-1 2^3 ∑ π, and it was delicious!

##### Share on other sites

I want to have this Delphi code translated to Autoit code...

day = (520161244 shr 24) and 256;

month = (520161244 shr 16) and 256;

year = 520161244 and 65535;

I am not shure how to do that. The result of this should be day month and year.

##### Share on other sites

Again, what is the output you expect? Are you trying to get the current day month and year? I'm not much into Delphi, so you have to give us an idea what you're trying to accomplish.

√-1 2^3 ∑ π, and it was delicious!

##### Share on other sites

Borje,

Where did you get those expressions? Because I do not think they are correct.

The number 520161244 is obviously an encoded date DDMMYYYY where each element is expressed in Hex. To extract the values we need to do the following:

For the day, BitShift right 24 - that just leaves the DD part

For the mon we BitShift right 16 - which leaves DDMM. We only want the MM part so we need to BitAND with 0x00FF to leave just the MM

For the yr we just need the final YYYY - so we BitAnd with 0xFFFF

In AutoIt that translates as:

```\$iDTG = 520161244

ConsoleWrite(Hex(\$iDTG) & @CRLF)

\$iDay = BitShift(\$iDTG, 24)

ConsoleWrite(\$iDay & @CRLF)

\$iMon = BitAnd(BitShift(\$iDTG, 16),0xFF)

ConsoleWrite(\$iMon & @CRLF)

\$iYear = BitAnd(\$iDTG, 0xFFFF)

ConsoleWrite(\$iYear & @CRLF)```

So I reckon we are looking at 31 Jan 2012.

As I said above, I think your expressions are wrong - they certainly did not work for me.

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Hello Melba23

Thank you very much for this example that is correct 31 Jan 2012 that result is that I want you give

a very good example that I learn from..

##### Share on other sites

Yes it is encoded date the result be 31-1-2012 and that is ok but how to show 31-01-2012

##### Share on other sites

Borje,

Look at StringFormat in the Help file. When you are thoroughly confused by the function and its complicated parameters, come back and I will explain.

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Melba23

I have now look in the helpfile but I am very confused and coplicated parameters i need help with this too

##### Share on other sites

Borje,

I did warn you it was a very complicated function - but here we need only concern ourselves with the simple problem of adding leading zeroes to the day and month if required.

To do that with your date values we use the parameter %02i:

```%  -  It is a format
0  -  Pad with zeroes if required to be at least...
2  -  The minimum width
i  -  It is an integer so the width affects the digits before the decimal point```

So you need:

```\$iDTG = 520161244

ConsoleWrite(StringFormat("%02i", BitShift(\$iDTG, 24)) & "-" & StringFormat("%02i", BitAnd(BitShift(\$iDTG, 16),0xFF)) & "-" & BitAnd(\$iDTG, 0xFFFF) & @CRLF)```

Clearer now?

M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

##### Share on other sites

Thank you Melba23

Yes now I understand a liitle bit more I have much to learn from your examples, but thank yoy very much for the help I got from you.

##### Share on other sites

Borje,

I did warn you it was a very complicated function - but here we need only concern ourselves with the simple problem of adding leading zeroes to the day and month if required.

To do that with your date values we use the parameter %02i:

```%  -  It is a format
0  -  Pad with zeroes if required to be at least...
2  -  The minimum width
i  -  It is an integer so the width affects the digits before the decimal point```

So you need:

```\$iDTG = 520161244

ConsoleWrite(StringFormat("%02i", BitShift(\$iDTG, 24)) & "-" & StringFormat("%02i", BitAnd(BitShift(\$iDTG, 16),0xFF)) & "-" & BitAnd(\$iDTG, 0xFFFF) & @CRLF)```

Clearer now?

M23

Continuing on with Melba23's example (of post #12), we have another two simple, valid methods to format a string for display purposes.

```Local \$iDTG = 520161244

; Melba23's (Combination of StringFormat functions and string concatenation.)
ConsoleWrite(StringFormat("%02i", BitShift(\$iDTG, 24)) & "-" & StringFormat("%02i", BitAND(BitShift(\$iDTG, 16), 0xFF)) & "-" & BitAND(\$iDTG, 0xFFFF) & @CRLF)

; Using one StringFormat function.
ConsoleWrite(StringFormat("%02i-%02i-%4i", BitShift(\$iDTG, 24), BitAND(BitShift(\$iDTG, 16), 0xFF), BitAND(\$iDTG, 0xFFFF)) & @LF)

; String concatenation. (StringRight function used to add leading zero - if only one digit exists.)
ConsoleWrite(StringRight("0" & BitShift(\$iDTG, 24), 2) & "-" & StringRight("0" & BitAND(BitShift(\$iDTG, 16), 0xFF), 2) & "-" & BitAND(\$iDTG, 0xFFFF) & @LF)

#cs
Console output:-
31-01-2012
31-01-2012
31-01-2012
#ce```

## Create an account

Register a new account

×

• Wiki

• Back

• Git