dainsleif 0 Posted January 13, 2005 hi all i am trying to code a function that reads triplets of nubers out of a string ($klartext) with the length $anzahl and converts them to chars the function works as far as (means i'm getting the expected triplets) $klar=stringtrimright($klar,stringlen($klar)-3) but it won't convert the number into char func konvtotxt($klartext,$anzahl) $klartxtout=fileopen("decrypt.txt",1) if mod($anzahl,2)=1 then $anzahl=$anzahl+1 endif for $i=0 to $anzahl/3 $klar=$klartext $klar=stringtrimleft($klar,$i*3) $klar=stringtrimright($klar,stringlen($klar)-3) $klartxt=chr($klar) filewrite($klartxtout, $klartxt) next fileclose($klartxtout) endfunc any ideas? Share this post Link to post Share on other sites
phillip123adams 0 Posted January 13, 2005 $klar=stringtrimright($klar,stringlen($klar)-3)but it won't convert the number into charfunc konvtotxt($klartext,$anzahl) endfuncWhat are the values you are passing to CHR? Are they all numeric? Please provide a sample of how you are calling to the konvtotxt function (including the values for its parameters). Phillip Share this post Link to post Share on other sites
JSThePatriot 18 Posted January 13, 2005 (edited) Func konvtotxt($klartext,$anzahl) $klartxtout=FileOpen("decrypt.txt",1) If Mod($anzahl,2)=1 Then $anzahl=$anzahl+1 EndIf For $i=0 To $anzahl/3 $klar=$klartext $klar=StringTrimLeft($klar,$i*3) $klar=StringTrimRight($klar,StringLen($klar)-3) $klartxt=Chr(Int($klar)) FileWrite($klartxtout, $klartxt) Next FileClose($klartxtout) EndFunc Try the above modified code and let me know how it turns out. I also made your code a bit more readable. Let me know, JS Edited January 13, 2005 by JSThePatriot AutoIt LinksFile-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.ComputerGetInfo UDF's Updated! 11-23-2006External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Share this post Link to post Share on other sites
dainsleif 0 Posted January 13, 2005 Func konvtotxt($klartext,$anzahl) $klartxtout=FileOpen("decrypt.txt",1) If Mod($anzahl,2)=1 Then $anzahl=$anzahl+1 EndIf For $i=0 To $anzahl/3 $klar=$klartext $klar=StringTrimLeft($klar,$i*3) $klar=StringTrimRight($klar,StringLen($klar)-3) $klartxt=Chr(Int($klar)) FileWrite($klartxtout, $klartxt) Next FileClose($klartxtout) EndFuncTry the above modified code and let me know how it turns out. I also made your code a bit more readable.Let me know,JS<{POST_SNAPBACK}>this code works now! thx a lot..seems as if the only thing missing wass the explicit conversion to intthe string passed to the function was 049050 in my testcase.. Share this post Link to post Share on other sites
JSThePatriot 18 Posted January 13, 2005 Glad to have been able to help. JS AutoIt LinksFile-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.ComputerGetInfo UDF's Updated! 11-23-2006External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Share this post Link to post Share on other sites