From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Byte Array To String numbers

Solved!
Go to solution

I'm trying to use "Byte Array To string"  If I display the array of bytes I can see the last two elements are the numbers 4 and 8 (ASCII 52 56) but when I use the "Byte Array To String" and add an indicator the 48 is missing???  Does this pallet ignore number 0-9?  Is there another way to easily convert a byte array to a string with numbers.  What am I doing wrong? 

I'm searching but I cant believe I cant find an example of this?

0 Kudos
Message 1 of 21
(6,725 Views)

A decimal 52 and 56 are correctly converted to 4 and 8. Why don't you run the VI then go to Edit>Make Current Values Default. Save that and attach it. No other way to see what is going on.

 

An alternative is the typecast function but since the Byte Array to String will work the same way, don't see what difference that will make.

Message 2 of 21
(6,721 Views)

Byte array to string does not lose or add anything. Maybe you should change the display format of the string to hex or \-codes to also show unprintable characters. (right-click..).

 

Your attached example is useless for us. Could you attach one where the pName indicator has a typical default value (run the VI, make all values default...save...attach again).

 

0 Kudos
Message 3 of 21
(6,720 Views)

OK this is it with output saved as defaults I'll try and tweek the displayedstring properties maybe thats the problem?

0 Kudos
Message 4 of 21
(6,714 Views)

the 48 is on the second line. Make sure to also resize the string indicator vertically.

The problem is all your null characters, making LabVIEW to split the line at the "-" character.

Message 5 of 21
(6,712 Views)

OK progress if I change to "/' codes Display" from normal I see the 48 but also the rest of the 256 /00/00/00/00....

Now how do I properly trim the string down with the returned 11 size of the array  prameter.

Read somthing about this but not sure how to do it properly.

sorry I'm not an experienced Labview guy I'm a C, C++, C# software engineer.

But I'm learning a lot more LabVIEW as I go on with this project.

Benn using labview off and on for 15 years but this is the deepest Ive dug inot it.

Thanks alot for the help and patience I really appreciate it.

0 Kudos
Message 6 of 21
(6,705 Views)

Oh wow ther it is on the second line.  Kool.

Why is it on a second line?

0 Kudos
Message 7 of 21
(6,698 Views)

I didnt split it untill after the second '"-"  dash.  and then the number then it injected a newline or something.

Interesting.  not sure why.

0 Kudos
Message 8 of 21
(6,695 Views)

The problem is that LabVIEW potentially wraps the lines at spaces and dashes and considers the 48\00\00\00\00... one long word, thus placing it on the second line because it does not fit on the first line.

 

I think LabVIEW should also be able to automatically wrap at any unprintable character. I'll write it up as an idea. 😄 Stay tuned.

Message 9 of 21
(6,691 Views)

Oh yeh that totally makes sense.

I bet if I get the resize done properly it will display on one line.

ie the pNmae size parameter comes back as 11 though I didnt save that with the default trick you showed my so you couldnt see that.

Must ba a way to link that retval back into the the array or the string.  I know Labview doent want you to resize arrays  but has a way to do it I'll read up on it now.  

0 Kudos
Message 10 of 21
(6,683 Views)