Borje Posted January 23, 2012 Share Posted January 23, 2012 (edited) Hi all AutoIt users Please I need help. 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 January 24, 2012 by Borje Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 23, 2012 Moderators Share Posted January 23, 2012 Hi, Borje. AutoIT does indeed support shifting. Check out BitShift in the help file. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Borje Posted January 23, 2012 Author Share Posted January 23, 2012 Thanks JLogan3o13For your answer about bitshift but I still need help to convert to Autoit code. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 23, 2012 Moderators Share Posted January 23, 2012 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? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Borje Posted January 23, 2012 Author Share Posted January 23, 2012 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. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 23, 2012 Moderators Share Posted January 23, 2012 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. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 23, 2012 Moderators Share Posted January 23, 2012 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 partFor 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 MMFor the yr we just need the final YYYY - so we BitAnd with 0xFFFFIn 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Borje Posted January 24, 2012 Author Share Posted January 24, 2012 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.. Link to comment Share on other sites More sharing options...
Borje Posted January 24, 2012 Author Share Posted January 24, 2012 Yes it is encoded date the result be 31-1-2012 and that is ok but how to show 31-01-2012 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 24, 2012 Moderators Share Posted January 24, 2012 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Borje Posted January 24, 2012 Author Share Posted January 24, 2012 Melba23 I have now look in the helpfile but I am very confused and coplicated parameters i need help with this too Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 24, 2012 Moderators Share Posted January 24, 2012 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 pointSo 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 Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Borje Posted January 24, 2012 Author Share Posted January 24, 2012 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. Link to comment Share on other sites More sharing options...
Malkey Posted January 24, 2012 Share Posted January 24, 2012 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now