amarcruz Posted March 28, 2012 Share Posted March 28, 2012 Run this code: #include-once AutoItSetOption("MustDeclareVars", 1) Func _DebugOut($s) ConsoleWrite($s & @CRLF) EndFunc Local $b = Binary("0x2000200A") _DebugOut("BinaryToInt1: "& BinaryToInt1($b, 20,4)) _DebugOut("BinaryToInt2: "& BinaryToInt($b, 20,4)) Func BinaryToInt1(Const ByRef $byteStr, $start = 1, $size = 4) $start -= 1 Local $ax = StringToASCIIArray(BinaryToString($byteStr,1), $start, $start+$size, 1) If Not IsArray($ax) Then _DebugOut("***BinaryToInt1 : start="&$start&", end="&($start+$size)&", Type $ax: "& VarGetType($ax)) Return 0 EndIf Local $ix, $nx = $ax[0] For $ix = 1 To UBound($ax)-1 $nx = BitShift($nx, -8) + $ax[$ix] Next Return $nx EndFunc Func BinaryToInt2(Const ByRef $byteStr, $start = 1, $count = 4) Return Number(String(BinaryMid($byteStr, $start, $count))) EndFunc In BinaryToInt1(), StringToASCIIArray() with 20,4 should return "" For these things I left VBScript 5 years ago. Back to VFP. Link to comment Share on other sites More sharing options...
trancexx Posted March 28, 2012 Share Posted March 28, 2012 If you have bug to report then report it. You will get some dev's opinion and resolution. It's simple matter. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Bert Posted March 28, 2012 Share Posted March 28, 2012 If you have bug to report then report it. You will get some dev's opinion and resolution. It's simple matter.Second that. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Newb Posted March 28, 2012 Share Posted March 28, 2012 Your code doesn't even run properly lol I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it. Link to comment Share on other sites More sharing options...
amarcruz Posted March 29, 2012 Author Share Posted March 29, 2012 Sorry, too much work.after resting a fewhourseverything looks different, every language has oddities.and yes, I forgot the "2" of BinaryToInt2() :-(tnx Link to comment Share on other sites More sharing options...
jchd Posted March 30, 2012 Share Posted March 30, 2012 Then what about negating the title of your post? 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) Link to comment Share on other sites More sharing options...
amarcruz Posted March 30, 2012 Author Share Posted March 30, 2012 err... right.AutoIt is great. No dependencies, little learning curve, fast coding, easy GUI programming... and many more.A very very hard work free for us.but, the StringToASCIIArray return value is not reliable.From the specifications in help:"Return ValueSuccess: An array where each element is the UNICODE code of the character at the corresponding position. Failure: Returns an empty string."In the code above, StringToASCIIArray second parameter (start) is out of bounds, and must fail returning "".I'm wrong? Link to comment Share on other sites More sharing options...
amarcruz Posted March 30, 2012 Author Share Posted March 30, 2012 ...continued from previous post.Should I report this as bug?...and yes, the title of my post is incorrect, I'm sorry and I appreciate your work.Thank you again.(and sorry for my English, my language is Spanish). Link to comment Share on other sites More sharing options...
czardas Posted March 30, 2012 Share Posted March 30, 2012 (edited) I didn't try to run the broken code. I don't know what you want it to do but I got it doing something.AutoItSetOption("MustDeclareVars", 1) Func DebugOut($s) ; Conflict => _DebugOut already exists as a UDF function ConsoleWrite($s & @CRLF) EndFunc Local $b = Binary("0x2000200A") DebugOut("BinaryToInt1: "& BinaryToInt1($b, 20,4)) DebugOut("BinaryToInt2: "& BinaryToInt2($b, 20,4)) Func BinaryToInt1(Const ByRef $byteStr, $start = 1, $size = 4) $start -= 1 Local $ax = StringToASCIIArray(BinaryToString($byteStr,1), $start, $start+$size, 1) If Not IsArray($ax) Then DebugOut("***BinaryToInt1 : start="&$start&", end="&($start+$size)&", Type $ax: "& VarGetType($ax)) Return 0 EndIf Local $ix, $nx = $ax[0] For $ix = 1 To UBound($ax)-1 $nx = BitShift($nx, -8) + $ax[$ix] Next Return $nx EndFuncEditAfter playing around with this, I see what you are saying. If some of the parameters are out of bounds, it appears that the function reverts to default parameters. Whether this is intentional or not, I don't know. Edited March 30, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
jchd Posted March 30, 2012 Share Posted March 30, 2012 No problem with your english, mine is French!Yes there are a couple of issues with this function. First as you point out it forces the first parameter to 0 (default) when it's out of bounds or greater to the end point.Then its definition of the end bound is a bit strange (but that's way too late to fix since that would break code) and doesn't work as one would expect. Since this is supposed to be the index of the character before which it should stop, StringToASCIIArray("abc", 1, 1) should bark but it behaves as it was (correctly) invoked as StringToASCIIArray("abc", 1, 2)File a bug report but please only use something like#include <Array.au3>Local $a = StringToASCIIArray("012345", 1, 1)_ArrayDisplay($a)to describe it! 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) Link to comment Share on other sites More sharing options...
amarcruz Posted March 30, 2012 Author Share Posted March 30, 2012 I will. Thank you. 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