Jump to content

Saving


Recommended Posts

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

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

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

Edited by madsiddiqui
Link to comment
Share on other sites

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

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 by madsiddiqui
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...