LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can i insert zero

I have this data(4E4A 4632 3435 ),and i want insert zero between them like:(40E040A0 40603020 30403050)
someone can help me how to do this withe sample program
0 Kudos
Message 1 of 9
(3,570 Views)
Lot's of ways to do it, but one is to convert the string to a byte array, initialize the shift register of a for loop with an array twice as large and feed the original byte array into the for loop with auto-indexing on. In the for loop you put a replace array element function, wire the array from the shift register to that, multiply the index with two and wire that to the index input of the function, and then wire the auto-indexed array element to it...Put a byte array to string function outside the loop and wire the byte array from the right-hand shift register to it...the result is then the output of the byte array to string function. I've attached the code.
0 Kudos
Message 2 of 9
(3,570 Views)
diallo332@;

Well, it depends on how you are representing your data.

Assuming it is a regular string, then you can simply interleave zeroes.

If it is a HEX string, then the story is different. You want to insert 4 bits with the value 0 between each number.

I am attaching a VI that do both cases.

Regards;

Enrique Vargas
www.visecurity.com
www.vartortech.com
0 Kudos
Message 3 of 9
(3,570 Views)
There is a small error in the VI I included. decimal value 48 is a zero on a normal string. The HEX value is x30.
www.vartortech.com
0 Kudos
Message 4 of 9
(3,570 Views)
diallo332@ wrote:

> I have this data(4E4A 4632 3435 ),and i want insert zero between them
> like:(40E040A0 40603020 30403050)
> someone can help me how to do this withe sample program

Ok, I'm not sure, what sort of array you have and what you want. I think
you habe an U16 Array and want a resulting U32 Array (from how you
grouped the data)
Do I see this right, you want 4 Bit of data, and the rest of the byte
padded with zero?

Ok, I've made an example-vi. Hope it helps and does what you need.

http://marco.tedaldi.net/labview/vis/insert_zeros.vi

Maybe there are other (eventually faster?) solutions, but this is what I
would do.

Bye

Marco
0 Kudos
Message 5 of 9
(3,570 Views)
Thank you for replaying me, this is the sample i was looking for, Thank you very much,but how can i put all zero like this, in ahead not in back hex sting
040E040A 04060302 03040305 (4E4A 4632 3435 )
0 Kudos
Message 6 of 9
(3,570 Views)
It is just a quick modification to the previous VI. Because I still don't know the format of the string (or whatever you want to add the zeroes) I again included two ways of doing it. See the attachment.
www.vartortech.com
0 Kudos
Message 7 of 9
(3,570 Views)
Thank you very much,for your help,the sample it very
useful for me.
Thank you.
Diallo
0 Kudos
Message 8 of 9
(3,570 Views)
diallo332@ wrote:

> Thank you for replaying me, this is the sample i was looking for,
> Thank you very much,but how can i put all zero like this, in ahead not
> in back hex sting
> 040E040A 04060302 03040305 (4E4A 4632 3435 )

Ok... after "mask out the Nibbles" in the Diagram, I shift up the lowe
nibble by multiplying with 0x10(hex, means 16 in decimal).
You could jut leave this out und shift "down" the other nibble (with the
shift-function or with the "Quotient and Reminder"-Function).

The other way would have been to convert the whole thing to a string and
than operate on this. It might have been easier 🙂

Bye

Marco
0 Kudos
Message 9 of 9
(3,570 Views)