views:

150

answers:

2

I would like to split byte strings, for example "AAFF10DC", with spaces, so it becomes "AA FF 10 DC".

How to do this in AutoIt (v3)?

+1  A: 

This is sorta ugly, but it works:

$string = "AAFF10DC"

$strArray = StringSplit($string, "") ; No delimiter will separate all chars.

$strResult = ""

If IsEvenNumber($strArray[0]) Then

    For $i = 1 to $strArray[0] Step 2
        $strResult = $strResult & $strArray[$i] & $strArray[$i+1] & " "
    Next

    MsgBox(0, "Result", $strResult)

Else
    MsgBox(0, "Result", "String does not contain an even number of characters.")
EndIf

Func IsEvenNumber($num)
    Return Mod($num, 2) = 0
EndFunc
JohnForDummies
If you put it in a function, you don't see that it's ugly :PThank you :)
lesderid
A: 
SmOke_N