Jump to content
Sign in to follow this  

StrToByteArray(), ByteArrayToStr()

Recommended Posts


;) 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])
Return $x

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
Return StringTrimRight($sResult, StringLen($sDelim))


Edited by MKISH


:bye: Hey there, was I helpful?


My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.