Click here to Skip to main content
15,881,793 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want a program that say if it read "01" in one textbox, in another textbox it would print "A" and if "02", it would print "B" and if possible I would like it to be reversible, basically my own homemade translator if you will, any help would be appreciated.

EDIT:
I was wanting it for a text editing project I was working on


basically I have a combobox that will be my portal to the address I want
and for this example I want it to read from 0x2C840A to 0x02C8435 and get the hex values along the way and turn it into text.

This is the basic shape of what I have right now

What I have tried:

<pre>BinaryReader br = new BinaryReader(File.OpenRead(ofd.FileName));
string hexValues = null;
for (int v = 0x2C840A; v <= 0x02C8435; v++)
{
br.BaseStream.Position = v;
hexValues += br.ReadByte().ToString("X2");
if (Scriptbox.Text == "Test Message") Hexbox.Text = (hexValues);
Posted
Updated 14-Jun-17 4:04am
v3
Comments
Mehedi Shams 14-Jun-17 0:16am    
Hi Knightsurfer,

Are these the only two input/output pairs? Please post some of your code.
Knightsurfer 14-Jun-17 9:24am    
I was wanting to replicate some Rom editing tools because not many people have really bothered, right now I'm working on a text editor, which basically means I need the program to read hex data, convert it to a self made library of letters, and spit it out as Text, and then have a way to type text in and be able to write it back into hex.


so basically,go to address, read hex value, grab from table the letter for that hex value, move onto the next one, grab that, put the letter for that alongside the previous one.

then for the writing new code part for every letter inputted, write it in hex value.

BinaryReader br = new BinaryReader(File.OpenRead(ofd.FileName));
string hexValues = null;
for (int v = 0x2C840A; v <= 0x02C8435; v++)
{
br.BaseStream.Position = v;
hexValues += br.ReadByte().ToString("X2");
if (Scriptbox.Text == "Test Message") Hexbox.Text = (hexValues);


basicly I have a combobox that will be my portal to the address I want
and for this example I want it to read from 0x2C840A to 0x02C8435 and get the hex values along the way and turn it into text.

also, that code might not be working ^_^; I tweaked it a lil earlier, but I assume you get the idea?


here is what I'm going for at the moment
Richard MacCutchan 14-Jun-17 10:48am    
You can convert hex to characters and vice versa quite easily with a few lines of code; no need for such a translation table. However, if you do not understand such a basic aspect of computers then I think this editor may be a bit beyond you.
Knightsurfer 14-Jun-17 10:53am    
That may be the case right now, but I refuse to just give up ^ ^
thanks for the answer, I will try to take your suggestion and
go with it, and sorry for the misunderstanding.
Richard MacCutchan 14-Jun-17 10:56am    
No, it has always been the case since even before 1965 when I first started in IT. As I said, if you do not understand basic computer architecture then you are unlikely to get this done. Do yourself a big favour and learn the basics first.

1 solution

You'd create a list containing 01, 02 etc and another list containing A, B etc.

When translating forwards ie from 01 to A:

outputBox.Text = list2[list1.IndexOf(inputBox.Text)]

When translating backwards ie. from D to 04:
outputBox.Text = list1[list2.IndexOf(inputBox.Text)]


Explanation:

list1 contains 01, 02, 03, 04, 05 etc
list2 contains A, B, C, D, E etc

When converting from eg. 01 to A:

• Get its index in list1
• Set outputBox.Text to the item in list2 at the same index.
 
Share this answer
 
Comments
Knightsurfer 14-Jun-17 8:57am    
yeah, I guess I oversimplified what I wanted, thanks for trying tho ^ ^ I was wanting to replicate some Rom editing tools because not many people have really bothered, right now I'm working on a text editor, which basically means I need the program to read hex data, convert it to a self made library of letters, and spit it out as Text, and then have a way to type text in and be able to write it back into hex.

so basically,go to address, read hex value, grab from table the letter for that hex value, move onto the next one, grab that, put the letter for that alongside the previous one.

then for the writing new code part for every letter inputted, write it in hex value.

BinaryReader br = new BinaryReader(File.OpenRead(ofd.FileName));
string hexValues = null;
for (int v = 0x2C840A; v <= 0x02C8435; v++)
{
br.BaseStream.Position = v;
hexValues += br.ReadByte().ToString("X2");
if (Scriptbox.Text == "Test Message") Hexbox.Text = (hexValues);


basicly I have a combobox that will be my portal to the address I want
and for this example I want it to read from 0x2C840A to 0x02C8435 and get the hex values along the way and turn it into text.

also, that code might not be working ^_^; I tweaked it a lil earlier, but I assume you get the idea?


here is what I'm going for at the moment
F-ES Sitecore 14-Jun-17 10:16am    
So what's wrong with the proposed solution? (apart from it being fragile). What requirement doesn't it fulfil? And please don't respond with that same wall of text as it is not clear what you mean.
Knightsurfer 14-Jun-17 10:21am    
sorry, I'm new to this and this whole list thing, will it put it together like how I described in the example above? sorry for misunderstanding if you did give the right answer x.x

also, I edited my reply a few times, because I wasn't sure how to clear it up anymore, I am only into the basics at the moment and I don't know much, which is why I decided to do a project that covered alot of the things I wanted to know about.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900