Jump to content

amarcruz

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by amarcruz

  1. I see now. Thank you so much.
  2. I will. Thank you.
  3. ...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).
  4. 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 Value Success: 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?
  5. Sorry, too much work. after resting a fewhourseverything looks different, every language has oddities. and yes, I forgot the "2" of BinaryToInt2() :-( tnx
  6. ...but Number(Binary(0xFF00)) = Number(0xFF00) whatever ... I'll think about it and re-read the help file. tnx again
  7. I got it. 0xFF00 cast to Int32, then the value received by Binary() is [00 FF 00 00] (four bytes). Binary("0xFF00") don't cast. ...and Hex(<Binary>) <> Hex(<Number>) because Binary<>Number. :-) Thank you.
  8. 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.
  9. I'm not a math guru and I don't understand Binary: Test("A", Binary("0xFF00")) Test("B", Binary(0xFF00)) Test("C", 0xFF00) Func Test($nam, $val) ConsoleWrite($nam &": "& $val &@CR) ConsoleWrite("Number: "& Number($val) &", Int: "& Int($val) & _ ", Hex: "& Hex($val) &", Dec: "& Dec($val) &", 0+"& $nam &": "& (0+$val) &@CR) EndFunc Output: A: 0xFF00 Number: 255, Int: 255, Hex: FF00, Dec: 0, 0+A: 0 B: 0x00FF0000 Number: 65280, Int: 65280, Hex: 00FF0000, Dec: 0, 0+b: 0 C: 65280 Number: 65280, Int: 65280, Hex: 0000FF00, Dec: 414336, 0+n: 65280 Note the Hex/Dec output.
×
×
  • Create New...