Jump to content

problems wirh chr()


Recommended Posts

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

$klar=stringtrimright($klar,stringlen($klar)-3)

but it won't convert the number into char

func konvtotxt($klartext,$anzahl)
endfunc
What 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

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 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

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

<{POST_SNAPBACK}>

this code works now! thx a lot..

seems as if the only thing missing wass the explicit conversion to int

the string passed to the function was 049050 in my testcase..

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...