Made some adjustments to take advantage of ascan(). But had to comment out the non alpha-numeric elements of your array.
Code:
Dim $a,$sTestInfo,$sEncode,$sScanInfo,$index
$a=1
$ = Open (1,"c:\test.txt",5)
$ = Open (2,"c:\testinfo.txt")
$aLCase='a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','x','y','z',' ',
'1','2','3','4','5','6','7','8','9','0';,
;'~','!','@','#','$','%','^','&','*','(',')','_',
;'+','?','>','<',':','"','}','{','|','\',']','[','=','-',',','.','/'
$aEncode='57e4','3216','96DD','774F','G44s','nX19','56x4','Y13n','k4T0','o319','J439','7KYL','x324',
'39e6','G491','2c3B','9ZiN','4qT7','E976','0Ob4','3nX4','1m43','D9I1','07QZ','07Qz','fx3J','X1x5','x4X9',
'Gg76','954N','TX1A','GWAH','4q33','xtZ0','K1n3','j517','ZN3x'
$sTestinfo=ReadLine (2)
While @error = 0
$a = 1
Do
$sScaninfo=SubStr ($sTestinfo,$a,1)
$index = ascan($aLCase,$sScaninfo)
if $index > -1
$ = WriteLine (1,$aEncode[$index])
else
$ = Writeline(1,$sScaninfo)
EndIf
$a=$a+1
Until $sScanInfo=""
$ = WriteLine (1,@CRLF)
$sTestInfo= ReadLine (2)
Loop
$ = Close (1)
$ = Close (2)
Exit 0