08-16-2016 09:30 AM
Hello,
Question 1: I have a file of ascii characters and I would like to convert them to a HEX array, and specify the exact index [row,column] where to insert this elements. I can currently convert into HEX but the elements get inserted one after the other and I am not specifying the location.
Question 2: This full contains "NULL" characters which appear as a "space" and get converted to the wrong ascii character. Should I just put an if statement: "if character is space make it equal to 0"?
Thank you.
08-16-2016 09:36 AM
Hi algo,
this should do basically the same as your Vi does:
Why do you need to get subsets of single chars from your string?
Why do you use this shift register?
Why concatenate 1D arrays countaining just one element?
Why create a 2D array of bytes (U8) when your data source is a single string?
specify the exact index [row,column] where to insert this elements.
Please define row/column for a 1D array - your string is just a 1D array of bytes!
This full contains "NULL" characters which appear as a "space" and get converted to the wrong ascii character.
I don't think so. Please provide some proof!
08-16-2016 09:37 AM
How are you planning on dictating the index for the hex value as you convert?
for question 2, a simple if " ", then " "=0x00 would probably be the simplest conversion, yes.
08-16-2016 09:38 AM
You can insert elements into array to specified indices using Insert into Array Function: https://zone.ni.com/reference/en-XX/help/371361J-01/glang/insert_into_array/
-Remember that only an initialized array can be used for inserting into array with specified array size: https://zone.ni.com/reference/en-XX/help/371361J-01/glang/initialize_array/
-To your second question if you don't want to consider NULL yes you can keep condition to filter them.
08-16-2016 09:47 AM
This 1D string array is just a serial output of a 2D matrix from an FPGA. So I need to put it back into 2D form in Labview.
Ex: character[0] is [0,0]; character[0] is [0,46] etc.
Would it be easy to take those values from one 2D array and then put them into another 2D array, or go directly from the string to the indexed 2D array?
Thank you for the quick reply
08-16-2016 09:51 AM
Perhaps something like this?
08-16-2016 09:56 AM
-Edit in my previous post: Instead of insert into array use Replace Array subset.
-The below code shows an array 5x5 each with element 1.
-Then replacing the element in 1x3 with element 0.
08-16-2016 10:04 AM
Hi algo,
Ex: character[0] is [0,0]; character[0] is [0,46] etc.
Please explain this example! Why is char[0] equal to [0, 0], but then equal to [0, 46]?
When you know the size of the "matrix" you can convert your 1D array easily to a 2D array using ReshapeArray…
08-16-2016 10:08 AM
If the size of the matrix is known from the start, and data is given for each value in the matrix (ie, if the string is 123456789, and the resulting matrix would be [[1,2,3],[4,5,6],[7,8,9]], and not something like [[1,2,3,],[4,5,6,7],[8,,9,]]) then using GerdW's suggestion, then adding a reshape array to the 2D result might be helpful. (Then do a traverse to remove 0x20 from the array)
08-16-2016 10:12 AM
Sorry! Character[0] is [0,0] and then Character[1] is [0,46] my bad.