stormbreaker Posted May 2, 2012 Share Posted May 2, 2012 (edited) Hello all. I wrote these two functions StrToByteArray(), ByteArrayToStr() for using my GPS device from PC. Here we go: Func StrToByteArray($str) Const $StrLen = Int(StringLen($str)) Local $x[$StrLen] $b = StringSplit($str, "") For $i = 1 to $b[0] $x[$i -1] = StringToBinary($b[$i]) Next Return $x EndFunc Func ByteArrayToStr(Const ByRef $avArray, $sDelim = "", $iStart = 0, $iEnd = 0) If Not IsArray($avArray) Then Return SetError(1, 0, "") If UBound($avArray, 0) <> 1 Then Return SetError(3, 0, "") Local $sResult, $iUBound = UBound($avArray) - 1 If $iEnd < 1 Or $iEnd > $iUBound Then $iEnd = $iUBound If $iStart < 0 Then $iStart = 0 If $iStart > $iEnd Then Return SetError(2, 0, "") For $i = $iStart To $iEnd $sResult &= BinaryToString($avArray[$i]) & $sDelim Next Return StringTrimRight($sResult, StringLen($sDelim)) EndFunc Regards Edited May 2, 2012 by MKISH ---------------------------------------- :bye: Hey there, was I helpful? ---------------------------------------- My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1 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