dainsleif Posted January 13, 2005 Share 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? Link to comment Share on other sites More sharing options...
phillip123adams Posted January 13, 2005 Share 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 Link to comment Share on other sites More sharing options...
JSThePatriot Posted January 13, 2005 Share 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 Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
dainsleif Posted January 13, 2005 Author Share 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.. Link to comment Share on other sites More sharing options...
JSThePatriot Posted January 13, 2005 Share Posted January 13, 2005 Glad to have been able to help. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now