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.