Sign in to follow this  
Followers 0
slaughter

HELP! StringReplace

15 posts in this topic

Well i got disapointed.....

3 days I was trying to make my script..... I made one type... nor workig some strange errors.... second..errors... and so on...

Finaly when i got fu*k*d up tears in eays... pain in head

I thougt what a hell I will make it simple... I made simple scrpit and find out

FileOpen($file, 1)
$chars = FileRead($file)
FileClose($file)
FileDelete($file)
$chars = StringReplace($chars, chr(0), "[chr0]")
Send_to_TCP_server($chars)

$chars = Rec_from_client()
$chars = StringReplace($chars, "[chr0]", chr(0))
FileOpen($file, 1)
$chars = FileWrite($file)
FileClose($file)

Shuld convert and reconvert withuot any problems? Is it ?

HELL NO!!!!!!!!!

Thats what I GET!

Thats how it loks before replacing receved from client in server side

˙Ų˙ą[chr0]JFIF[chr0][chr0]`[chr0]`[chr0][chr0]˙Ū[chr0]C[chr0]

(1#%(:3=<9387@H\N@DWE78PmQW_bghg>Mqypdx\egc˙Ū[chr0]C//c


Just a part of JPG file. File size ~200kb

After using replace. All 200kb file loks like 30 Bytes:

˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[˙Ų˙ą[

It is bug? O my easy is tired and i am total dummy.........

Share this post


Link to post
Share on other sites



I don't believe you really need to replace the characters. Just read it as a binary string, then send that binary string. Try it.

Share this post


Link to post
Share on other sites

I don't believe you really need to replace the characters. Just read it as a binary string, then send that binary string. Try it.

You hve in mind

FileOpen($file, 16)
$chars = FileRead($file)
FileClose($file)
FileDelete($file)
;;;;;$chars = StringReplace($chars, chr(0), "[chr0]")
Send_to_TCP_server($chars)






$chars = Rec_from_client()
;;;;;;;;;;;;;;;;$chars = StringReplace($chars, "[chr0]", chr(0))
FileOpen($file, 1)
$chars = FileWrite($file)
FileClose($file)

smth like this?

Sory I have not much EXP in data transfer and how wuld be helpfull to post some info... for numb nut....

Share this post


Link to post
Share on other sites

FileOpen + Binary Mode

String + BinaryToString + FileRead

Replace (hex values for char whatever)

StringToBinary + FileWrite

FileClose


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

FileOpen + Binary Mode

String + BinaryToString + FileRead

Replace (hex values for char whatever)

StringToBinary + FileWrite

FileClose

WOW Nice idea!!!!!!!! YOU ARE MY GOD! :) Kisses and hugs!

WORKING!!!

unc make_jpg_file($fn)


$file = FileOpen($fn, 16)
; Check if file opened for writing OK
$chars = String(BinaryToString(FileRead($file)))
FileClose($file) 
FileDelete($file)


$file = FileOpen($fn, 16)

$String = "[chr0]"
$Hex = _StringToHex($String)
$Hexg = _StringToHex(chr(0))


$data= StringReplace(string(BinaryToString($chars)), $Hex, $Hexg)
FileWrite($file, StringToBinary($data))
FileClose($file)   
EndFunc

Share this post


Link to post
Share on other sites

WOW Nice idea!!!!!!!! YOU ARE MY GOD! :) Kisses and hugs!

WORKING!!!

unc make_jpg_file($fn)
$file = FileOpen($fn, 16)
; Check if file opened for writing OK
$chars = String(BinaryToString(FileRead($file)))
FileClose($file) 
FileDelete($file)
$file = FileOpen($fn, 16)

$String = "[chr0]"
$Hex = _StringToHex($String)
$Hexg = _StringToHex(chr(0))
$data= StringReplace(string(BinaryToString($chars)), $Hex, $Hexg)
FileWrite($file, StringToBinary($data))
FileClose($file)   
EndFunc
Don't know about "God" ... I just know I've messed with it enough lately to know what issues you are having.

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Don't know about "God" ... I just know I've messed with it enough lately to know what issues you are having.

YOU ARE MY GOD! ;) Kisses and hugs!

.... by "slaughter" no less

.... :)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

This guy is praising you for pseudcode Smoke! I wish bitches in HR would pray to me when I write 1000+ php lines of code.

Share this post


Link to post
Share on other sites

This guy is praising you for pseudcode Smoke! I wish bitches in HR would pray to me when I write 1000+ php lines of code.

I hear that... people in my office don't even have a clue how much work goes into something, they look at it as just another app... :)

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I hear that... people in my office don't even have a clue how much work goes into something, they look at it as just another app... :)

Long time i worked IT Engenir in one company.....

Office pepole look to web and down evern thnk that to show his own vage on screan takes programer to write helll long script....

:/

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I shout for help now, I am trying to search in a text file for a setting. I am not sure of the best way to search through the file looking for something. I would be looking for this.

Give_Something = *

and I want to read this then replace it with Give_Something = '"ABC C:\prg\thing" %f %p-' I just get errors

Any help would be good.

Thanks

Joe :)

Edited by joos

Share this post


Link to post
Share on other sites

I shout for help now, I am trying to search in a text file for a setting. I am not sure of the best way to search through the file looking for something. I would be looking for this.

Give_Something = *

and I want to read this then replace it with Give_Something = '"ABC C:\prg\thing" %f %p-' I just get errors

Any help would be good.

Thanks

Joe :)

Found it now! Teachers Note

*Must look harder* For anyomnne else looking I am using StringReplace

Share this post


Link to post
Share on other sites

I shout for help now, I am trying to search in a text file for a setting. I am not sure of the best way to search through the file looking for something. I would be looking for this.

Give_Something = *

and I want to read this then replace it with Give_Something = '"ABC C:\prg\thing" %f %p-' I just get errors

Any help would be good.

Thanks

Joe :)

StringReplace have bug. If you uses it with not normal charekters [0-9, a-z,A-Z, anyting on keybord] will work well but if using like reading from file? Here bugs strats!!!!

if yu dint get any result from sringreplace() with normal varibles

try convert everyting to binary! look at my script

http://www.autoitscript.com/forum/index.php?showtopic=54601

there i solved out all problems with string replace,slpit write ;)

Share this post


Link to post
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
Sign in to follow this  
Followers 0