read hexadecimalvalues one by one out from a file 
Author Message
 read hexadecimalvalues one by one out from a file

hi,
  I am confused of reading and writing hex-value in/from a file. I
want to read out hex-value just value by value from a file , in which
the hex-values with original type UCHAR in the form"0xAC" are stored
through CFile::WriteString in a structure that there are same number
of hex-values in every line. e.g. in a line there are 6 hex-values,
every has 2 digits just like this: AC121C4DCDBB.
I want to read them out again and put every hex-value in a single
Editbox. I tried to use ReadString but it read the all values in the
line out but not the single value, I input the values in the file with
a "\n" every 6 values. but how can I get the single value again? I
mean how can I identify  not only the single hex-value but also the
changing of the line?

every help would be appreciated, thanks.

Sascha



Sat, 12 Feb 2005 18:44:05 GMT  
 read hexadecimalvalues one by one out from a file
Well, hex values are the same as decimal values are the same as character values. Hex is
just a representation for bits. So is decimal. So are characters. So I'm not sure what
your question is. There are better wordings that are technically correct.

"I want to read binary values a byte at a time from a file. I then want to convert the
byte value to a printable hexadecimal representation"

or you are asking

"I have a file which is a text file, in which every pair of characters represents a single
hexadecimal byte, and there are six character pairs per line, with no intervening spaces.
I wish to read a line of such characters into the program, and write the same characters
back out, that is, copy the file"

Then there is the edit box, which might be asked as
"I wish to write these lines of text into a multiline edit box, with 12 hexadecimal digits
per line in the control"

What do you mean by "how can I get the single value again?" since you have clearly
specified there are either 12 hex digits or 6 bytes of data, and none of these tell me
what a "single" value is"

I also do not understand quite what you mean about the "changing of the line". Do you mean
that you would like to detect when a line of hex digits has changed in the edit control?

Note that ReadString is defined to read in an entire line, so if you have a line,
ReadString will read all of it. If you want to read a single byte, use Read(), which is a
method of the superclass CFile.

Perhaps a picture would help, e.g.,

The file contains
000000000000
111111111111
123456789ABC
FEDCBA98765

etc. What I want to do is read the data in and write it back out to another file. How do I
do this?

Or

etc. What I want to do is read the data in and display it in a multiline edit control.
After the user has edited it, I want to write it back out.

Or:

etc. What I want to do is read the data in and display it in a multiline edit control.
After the user has edited it, but only if the user has edited it, I want to write it back
out.

Or:

etc. What I want to do is read the data in and display it in a multiline edit control.
After the user has edited it, but only if the contents have changed, I want to write it
back out. If the user makes a change and undoes it so the original data is restored, I
don't want to write it back out.

These are just some of the variants you might be asking. Clarify which one and I can give
you an anser, but I don't want to answer all of them.
                                        joe


Quote:
>hi,
>  I am confused of reading and writing hex-value in/from a file. I
>want to read out hex-value just value by value from a file , in which
>the hex-values with original type UCHAR in the form"0xAC" are stored
>through CFile::WriteString in a structure that there are same number
>of hex-values in every line. e.g. in a line there are 6 hex-values,
>every has 2 digits just like this: AC121C4DCDBB.
>I want to read them out again and put every hex-value in a single
>Editbox. I tried to use ReadString but it read the all values in the
>line out but not the single value, I input the values in the file with
>a "\n" every 6 values. but how can I get the single value again? I
>mean how can I identify  not only the single hex-value but also the
>changing of the line?

>every help would be appreciated, thanks.

>Sascha

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Sun, 13 Feb 2005 09:10:23 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating separate text files from one large one

2. VS.NET: Adding one .cs file to more then one project

3. Q: reading one byte from binary file ???

4. reading a file into a dynamic array in one pass

5. read all files at one time

6. read all files at one time

7. Fastes Method of File I/O for reading one line at a time

8. comparing digits one by one

9. passing more than one type of argument to one function

10. Create one singleton object in other interface's method (in one project)

11. How to add one to one relationship in access97 database thru SQL

12. turn one computer into more than one

 

 
Powered by phpBB® Forum Software