madsiddiqui Posted September 9, 2011 Share Posted September 9, 2011 I made an editor, Allows me to open a file, edit, etc... Then here comes the SAVING part... Normally when you save it writes to the file, Like if I edited it to "HELLO".HELLO will be saved into the file. What I need is SAVING it as a HEX file, Like if I edited it to "48454c4c4f".HELLO will still be saved into the file. Note: I've tried hex2string on saving, it works but with a few problems. the hex "1D" when saving hex2string("1D"), doesn't do it correctly. It gives me nothing.When it should be giving me this: [GS] , refer to: Group separator ("GS") : hex 1D That's why I need to insert it to hex directly not via hex2string function.How should I go about? Thanks... Link to comment Share on other sites More sharing options...
UEZ Posted September 9, 2011 Share Posted September 9, 2011 You mean something like that? #include <String.au3> $hFile = FileOpen("Test.bin", 2) $bString = _StringToHex("HELLO") FileWrite($hFile, $bString) FileClose($hFile) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
madsiddiqui Posted September 9, 2011 Author Share Posted September 9, 2011 (edited) You mean something like that? #include <String.au3> $hFile = FileOpen("Test.bin", 2) $bString = _StringToHex("HELLO") FileWrite($hFile, $bString) FileClose($hFile) Br, UEZ Something like this sir, #include <String.au3> $hFile = FileOpen("Test.bin", 17) $bString = _HexToString("1d2423") FileWrite($hFile, $bString) FileClose($hFile) When I view the file i see, correct values Edited September 9, 2011 by madsiddiqui Link to comment Share on other sites More sharing options...
UEZ Posted September 9, 2011 Share Posted September 9, 2011 Cool, you did it! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
madsiddiqui Posted September 9, 2011 Author Share Posted September 9, 2011 One more question, when saving the hex file it gives me 0x at the start? How do I get rid of that? Link to comment Share on other sites More sharing options...
UEZ Posted September 9, 2011 Share Posted September 9, 2011 Look at StringMid() function. E.g. $s = "0x12345678" ConsoleWrite(StringMid($s, 3) & @CRLF) Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
madsiddiqui Posted September 9, 2011 Author Share Posted September 9, 2011 (edited) This code should work for me, but I need advice on the StringReplace, I have so many strings to replace. Any alternative way to get many strings replaced? like #include <String.au3> $hFile = FileOpen("Test.bin", 18) $hFile2 = FileOpen("Test2.bin", 0) $chars = FileRead($hFile2) $SH = StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($chars, "", @TAB, 0 ,1), "", @CRLF, 0 ,1), "9" ,"-", 0 ,1), "4" ," ", 0 ,1), "7" ,"#", 0 ,1) $bString = _StringToHex($SH) FileWrite($hFile, _HexToString($bString)) FileClose($hFile) Some of the strings I need to: " " => "4","!" => "5",100 more strings to be replaced. all 4 become space, or all space becomes 4. Edited September 9, 2011 by madsiddiqui 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