p2p2,
I strongly suggest you rewrite your function to use arrays and loops - then it will be easier to debug.
This shows how you might do it - you will obviously need to make the array much bigger, but the rest of the code is good.
#include <Array.au3>
$sText = "abcba"
$sRet = _HEX($sText)
ConsoleWrite($sRet & @CRLF)
ConsoleWrite(@CRLF)
$sRet = _New_HEX($sText)
ConsoleWrite($sRet & @CRLF)
Func _New_HEX($text)
Local $aTrans[3][6] = [ _
["A", "6", "9", "f", "9", "9"], _
["B", "e", "9", "e", "9", "e"], _
["C", "6", "8", "8", "8", "6"]]
Local $aHex[6] = [0, "", "", "", "", ""]
For $i = 1 To StringLen($text)
$sChar = StringUpper(StringMid($text, $i, 1))
$iIndex = _ArraySearch($aTrans, $sChar)
If $iIndex <> -1 Then
For $j = 1 To 5
$aHex[$j] &= $aTrans[$iIndex][$j] & " "
Next
EndIf
Next
$sRet = ""
For $i = 1 To 5
$sRet &= $aHex[$i] & @CRLF
Next
Return $sRet
EndFunc ;==>_HEX
Func _HEX($text)
Local $hex1, $hex2, $hex3, $hex4, $hex5
$hex1 = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($text, " ", "0 "), "A", "6 "), "B", "e "), "C", "6 "), "D", "e "), "E", "f "), "F", "f "), "G", "6 "), "H", "9 "), "I", "6 "), "J", "f "), "K", "9 "), "L", "8 "), "M", "9 "), "N", "d "), "O", "6 "), "P", "e "), "Q", "6 "), "R", "e "), "S", "6 "), "T", "f "), "U", "9 "), "V", "9 "), "W", "9 "), "X", "9 "), "Y", "9 "), "Z", "f "), " ", " "), "!", "6 ")
$hex2 = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($text, " ", "0 "), "A", "9 "), "B", "9 "), "C", "8 "), "D", "9 "), "E", "8 "), "F", "8 "), "G", "8 "), "H", "9 "), "I", "6 "), "J", "1 "), "K", "9 "), "L", "8 "), "M", "f "), "N", "d "), "O", "9 "), "P", "9 "), "Q", "9 "), "R", "9 "), "S", "8 "), "T", "6 "), "U", "9 "), "V", "9 "), "W", "9 "), "X", "9 "), "Y", "9 "), "Z", "1 "), " ", " "), "!", "6 ")
$hex3 = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($text, " ", "0 "), "A", "f "), "B", "e "), "C", "8 "), "D", "9 "), "E", "f "), "F", "f "), "G", "8 "), "H", "f "), "I", "6 "), "J", "1 "), "K", "e "), "L", "8 "), "M", "9 "), "N", "f "), "O", "9 "), "P", "e "), "Q", "9 "), "R", "e "), "S", "6 "), "T", "6 "), "U", "9 "), "V", "9 "), "W", "9 "), "X", "6 "), "Y", "6 "), "Z", "6 "), " ", " "), "!", "6 ")
$hex4 = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($text, " ", "0 "), "A", "9 "), "B", "9 "), "C", "8 "), "D", "9 "), "E", "8 "), "F", "8 "), "G", "9 "), "H", "9 "), "I", "6 "), "J", "1 "), "K", "9 "), "L", "8 "), "M", "9 "), "N", "b "), "O", "9 "), "P", "8 "), "Q", "b "), "R", "9 "), "S", "1 "), "T", "6 "), "U", "9 "), "V", "6 "), "W", "f "), "X", "9 "), "Y", "6 "), "Z", "8 "), " ", " "), "!", "0 ")
$hex5 = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($text, " ", "0 "), "A", "9 "), "B", "e "), "C", "6 "), "D", "e "), "E", "f "), "F", "8 "), "G", "7 "), "H", "9 "), "I", "6 "), "J", "6 "), "K", "9 "), "L", "f "), "M", "9 "), "N", "b "), "O", "6 "), "P", "8 "), "Q", "7 "), "R", "9 "), "S", "6 "), "T", "6 "), "U", "6 "), "V", "6 "), "W", "9 "), "X", "9 "), "Y", "6 "), "Z", "f "), " ", " "), "!", "6 ")
Return StringReplace(StringReplace($hex1&"!"&@CRLF&$hex2&"!"&@CRLF&$hex3&"!"&@CRLF&$hex4&"!"&@CRLF&$hex5&"!", " ", " "), " !", "")
EndFunc ;==>_HEX
You will notice that the results from the 2 functions are not identical although I did use the data in your function. So I fear that you may have more then the one error in your existing code. At least this way you can check easily that you do have the correct values for each letter.
I hope this helps.
M23