LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

creating memory addresses

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.

0 Kudos
Message 1 of 13
(3,328 Views)

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?

0 Kudos
Message 2 of 13
(3,318 Views)

Here it is

 

 

Thank you

0 Kudos
Message 3 of 13
(3,309 Views)

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.

0 Kudos
Message 4 of 13
(3,306 Views)
0 Kudos
Message 5 of 13
(3,297 Views)
As I explained, I need to write the the elements of content array to a file. Each line of the file is an address. for example line 1 of the file will be address 0 and so on. This is if I write the elements of the content array to that file, the element 1 of that array will for sure go to line 1 instead of going to line 61 which its corresponding address. we want for example element 1 to go to its corresponding line (address) and in this case element 1 should go to lin 61 (to be translated to decimal bcause this is HEX), and element 2 should go to line 62 (its corresponding line address)...and so on.
0 Kudos
Message 6 of 13
(3,294 Views)

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.

0 Kudos
Message 7 of 13
(3,286 Views)

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)

 

 

Download All
0 Kudos
Message 8 of 13
(3,283 Views)

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.

0 Kudos
Message 9 of 13
(3,277 Views)

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.Smiley Wink

Message 10 of 13
(3,275 Views)