04-22-2011 04:26 PM
Hi,
I urgently need to create a memory file to read from. Attached you have an array of addresses (in HEX) and an array of the content(in HEX) that should go to that address location. Here is what we want, we want to write (TO A TEXT FILE) ONLY THE ELEMENTS IN THE CONTENT ARRAY. But each element MUST GO TO its specific locations (addresses).
for example the content 1F MUST go to line 0x61 of the file; 15 must go to line 0x62 of the file....
Please your urgent help is needed.
04-22-2011 04:49 PM
Your controls are empty. Please make the current values the default after entering data, then save again and attach.
I don't know what you mean by "address". The file offset perhaps?
How is the file structured? Is it supposed to be a binary file or formatted ASCII with a delimiter (e.g. linefeed) separating records?
Are the records consecutive or will there be gaps?
04-22-2011 05:19 PM
Here it is
Thank you
04-22-2011 05:22 PM
You have not described the structure of the file, as altenbach asked. Is this a text file? Is it a binary file? If so, what is its format?
More importantly, what have you tried? Have you tried reading the contents of the file, replacing the appropriate lines, and then writing out the file? For instance, you can use the Read Text File to read a file by lines into an array.
04-22-2011 06:13 PM
04-22-2011 06:16 PM
04-22-2011 06:54 PM
Let's clarify the terminology a bit more. As Altenbach has said, files don't have "addresses". So I'll try to translate using your definitions. You say "each line of the file is an address". Generally when you use the word "line", that implies a text based file where the file is made up of data of varying lengths and it is separated by a carriage return or linefeed character to distinguish the lines from each other.
But your Contents array shows individual bytes in hex display. This is somewhat uncertain becuase your contents array is of the 64-bit integer datatype (meaning 8 bytes for each element), but all of the data in the array looks like is can be represented in 8 bits or 1 byte. So in this case, it seems like you have a binary array where each "address" represents a single byte in the file. If that is the case, then you can use the Set File Position function in the File I/O >> Advanced palette, to set your file pointer to a file offset and overwrite the byte there.
If you are actually dealing with a text file with variable length lines, then things get more complicated because you are going to have to read the file to determine where the line breaks are. And also be sure that when you write data, that you aren't going to accidentally overwrite data that belongs to the next line of the file.
04-22-2011 07:07 PM - edited 04-22-2011 07:09 PM
Maybe something like this can point you in the right direction....
Apparently, you want linefeeds. If you use a zero padded hexadecimal format, you can calculate the offset from the address. Modify as needed.
(To create a binary file instead, decide on a numeric representation for the 1D array, the write it directly to a binary file)
04-22-2011 07:54 PM
Thanks. Is it possible to remove the 0000, and also the first element 1F is starting at 98 instead of 97. A quick fixe could help. I tried but, it seems to drive me crazy again.
Thanks.
04-22-2011 07:59 PM
I'm sure if you study Altenbach's code, and using debugging tools like probes and highlight execution, you'll be able to figure it out and learn something in the process.