Xand3r Posted July 29, 2009 Share Posted July 29, 2009 (edited) int(0xffff)=65535 int(binarymid(0xffff0000,3,2))=255 ;binarymid(0xffff0000,3,2)=0xffff int(string(binarymid(0xffff0000,3,2)))=65535 any ideea why this would occur? $ss=BinaryMid(0xffff0000,3,2) MsgBox(0 ,"a test" , $ss & ":" & Int($ss) & @CRLF & "0xFFFF" & ":" & Int("0xFFFF") & @CRLF & "String("&$ss & "):" & Int(String($ss))) Edited July 29, 2009 by Xand3r Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
enaiman Posted July 29, 2009 Share Posted July 29, 2009 Kinda strange until I did a little bit of testing: $binary = "0xff12dd12345671" MsgBox (0, "1 - returns 2", BinaryMid($binary,1,1)) MsgBox (0, "2 - returns 4", BinaryMid($binary,1,2)) MsgBox (0, "3 - returns 6", BinaryMid($binary,1,3)) MsgBox (0, "4 - returns 8", BinaryMid($binary,1,4)) MsgBox (0, "5 - returns 10", BinaryMid($binary,1,5)) ;Notes1: Number of "bytes" to extract 1 byte = 2 hex characters ;Notes2: when the number ($binary) has an odd number of characters, the above function returns bad data To address your issue: $ss=BinaryMid(0xffff0000,3,1) MsgBox(0 ,"a test" , $ss & ":" & Int($ss)) SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted July 29, 2009 Share Posted July 29, 2009 I haven't tested but a wild guess it's because binary* adds 0x at the beginning of a value. >_ Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
Xand3r Posted July 29, 2009 Author Share Posted July 29, 2009 (edited) $binary = "0xff12dd12345671" MsgBox (0, "test", "" & _ "Int("&BinaryMid($binary,1,2)&"):"&@TAB&Int(BinaryMid($binary,1,2))& @CRLF & _ "Int(String("&BinaryMid($binary,1,2)&")):"&Int(String(BinaryMid($binary,1,2)))& @CRLF & _ "Int(0xff12):"&@TAB&Int(0xff12)) you didn't address anything mate... my problem is not with binarymid... :| is with int binarymid(value1) = value2 int(binarymid(value1)) < int (value2) edit: int(binarymid($binary,$x,$y)) never returns more than 255 but int has a limit of 65535... int(string(binarymid($binary,$x,$y))) return the right value AND int("0xXXXX") also return the right value (X=any hex char) bug? Edited July 29, 2009 by Xand3r Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
martin Posted July 29, 2009 Share Posted July 29, 2009 It's just that Int does not operate on binary parameters.I think it should return 0 and set @error to 1 when you pass a binary value.From the helpFailure: Returns 0 sets @error to 1 if not an integer, float or string.Though it would make sense for Int to be able to handle binary data. I would say that not returning 0 and setting @error to 1 when passed binary data is a bug, and having Int handle binary data is a feature request. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Ascend4nt Posted July 29, 2009 Share Posted July 29, 2009 @Xand3r: Interest, I didn't know that Binary data couldn't be converted with Int or Number (tested that myself) However, change your first line to this (from 1st post), and it works: $ss='0x'&Hex(BinaryMid(0xffff0000,3,2)) My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
Xand3r Posted July 30, 2009 Author Share Posted July 30, 2009 It's just that Int does not operate on binary parameters.I think it should return 0 and set @error to 1 when you pass a binary value.From the helpThough it would make sense for Int to be able to handle binary data. I would say that not returning 0 and setting @error to 1 when passed binary data is a bug, and having Int handle binary data is a feature request.tnx martin >_< that was the answer i was looking for and i know now why using string() worked Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro 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