JoeCool Posted May 23, 2010 Posted May 23, 2010 why 0x00270FF6 != 2559990 ? unsigned hex positive int32 can someone explain me that please if binary("0x00270FF6") = 2559990 then msgbox(0, "True", "" ) else msgbox(0, "False", "" ) endif
FuryCell Posted May 23, 2010 Posted May 23, 2010 (edited) Use Dec() instead. Binary() is for strings.$Val=Dec("00270FF6") if $Val = 2559990 then msgbox(0, "True", "" ) else msgbox(0, "False", "" ) endifEdit:Clarity Edited May 23, 2010 by FuryCell HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
JoeCool Posted May 23, 2010 Author Posted May 23, 2010 (edited) oh i see i found it.... binary( ) has nothing to do with hex number neither binary NUMBER (b10010100) ... it can take 2 forms of string not interpreted the same way... binary("abc") = binary("0x616263") $str = binary("hello world") is the same has $str = stringToBinary("hello world") who will just encode caracters to ascii byte default encoding value ... and binary("0x616263") is a raw encoding form ... EDIT i changed this message a few time... i was exploring the help file Edited May 23, 2010 by JoeCool
FuryCell Posted May 23, 2010 Posted May 23, 2010 (edited) standard strings are null terminated and thus Chr(0) will cause problems. This makes reading binary files fail because it will stop at the chr(0) which are common in binary files.Edit:updated after clarification by Jos Edited May 23, 2010 by FuryCell HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Developers Jos Posted May 23, 2010 Developers Posted May 23, 2010 A string cannot contain a NULL character as that terminates the string, Binary can. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
FuryCell Posted May 23, 2010 Posted May 23, 2010 A string cannot contain a NULL character as that terminates the string, Binary can.Thanks for clarifying. HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
JoeCool Posted May 23, 2010 Author Posted May 23, 2010 (edited) A string cannot contain a NULL character as that terminates the string, Binary can. yes , of course maybe usuful when i will code some read/write byte port (com, lpt, usb ... ) drivers in autoit ... something like ... $arr[1024] stuff with all strings and all protocol bytes (0x00 to 0xFF ) stringToBinary(stringFromASCIIArray($arr)) to have a byte buffer ... i should stop drinking beer now and go to sleep ! Edited May 23, 2010 by JoeCool
FuryCell Posted May 23, 2010 Posted May 23, 2010 (edited) i should stop drinking beer now and go to sleep ! You are in the same time zone as me. Its past 6 am and I'm still awake. What is it with us geeks and not sleeping? Edited May 23, 2010 by FuryCell HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
jchd Posted May 23, 2010 Posted May 23, 2010 A string cannot contain a NULL character as that terminates the string, Binary can.So StringToASCIIArray and StringFromASCIIArray functions are special from this point of view. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
trancexx Posted May 23, 2010 Posted May 23, 2010 So StringToASCIIArray and StringFromASCIIArray functions are special from this point of view. Probably more than one line is needed to explain handling properly. Context is very important. $sString = "abc" & Chr(0) & "def" & Chr(0) & "ghi" ConsoleWrite("AutoIt type is: " & VarGetType($sString) & @CRLF) ConsoleWrite("StringLen is " & StringLen($sString) & @CRLF) ConsoleWrite("First NULL is character No" & StringInStr($sString, Chr(0), 0, 1) & @CRLF) ConsoleWrite("Second NULL is character No" & StringInStr($sString, Chr(0), 0, 2) & @CRLF) ConsoleWrite("By replacing NULL with X I get " & StringReplace($sString, Chr(0), "X") & @CRLF) ;... ConsoleWrite("Is string terminated by NULL character?" & @CRLF) ♡♡♡ . eMyvnE
jchd Posted May 23, 2010 Posted May 23, 2010 Thanks for being less lazy/tired than I was. I try to avoid such situations like the plague as they are very error-prone, particularly when long-term maintenance is in view. Hence, unless NULs are imposed by external conditions, I stay away of them in any language where strings are zero-terminated. If unavoidale I treat them as arrays, collections, streams, lists, flux, ... whatever containers of suitable character type. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
trancexx Posted May 23, 2010 Posted May 23, 2010 (edited) AutoIt is great because its String...() functions, even RegExp (emphasizing this as a proof of something) handles NULL with no problems. Seems there are no limitations introduced additionally. I guess if some CE hax0r would know that there would be much less Nomadmem...whatever.au3 uber-scanning memory slow omg help me questions, if nothing. Edited May 23, 2010 by trancexx ♡♡♡ . eMyvnE
jchd Posted May 23, 2010 Posted May 23, 2010 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
wraithdu Posted May 25, 2010 Posted May 25, 2010 (edited) More to the OP's original mistake: Binary is stored in memory in byte order. In other words Binary("0x00270FF6") is stored as the bytes 00,27,0F,F6. However on Windows machines, integers are stored in Little Endian format, meaning 0x00270FF6 (or 2559990) is stored as the bytes F6,0F,27,00. So, ConsoleWrite(Int(Binary("0xF60F2700")) & @CRLF) ; = 2559990 ; actual bytes ConsoleWrite(Binary(0x00270FF6) & @CRLF) ConsoleWrite(Binary(2559990) & @CRLF) Edited May 25, 2010 by wraithdu
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