LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I convert a string to it's /codes version?

I am trying to convert a string of data from a serial port to it's /codes equivilant. I just want the final string to be the same thing that you would see in the string indicator if "'/' codes" mode was selected instead of Normal mode. This is the only way I can handle some of the data.
0 Kudos
Message 1 of 7
(4,130 Views)
Try this VI. When /codes are enabled on a string, the Text.Text property returns the string with /codes as it is displayed on the control.


LabVIEW, C'est LabVIEW

Message 2 of 7
(4,130 Views)
You would need to go through the string one char at a time looking for
\n \s \t \r etc. and substitute for these non printing characters with
the "codes" equivalents.

The tricky one to watch out for though will probably be the \
character which has a "codes" equivalent of \\. You could get stuck
in an endless loop if you don't code it right.

Douglas De Clue
LabVIEW developer
ddeclue@bellsouth.net

rcash wrote in message news:<5065000000080000008E4E0000-1023576873000@exchange.ni.com>...
> I am trying to convert a string of data from a serial port to it's
> /codes equivilant. I just want the final string to be the same thing
> that you would see in the string indicator if "'/' codes" mode was
> selected instead of Normal mode. This is the only w
ay I can handle
> some of the data.
0 Kudos
Message 3 of 7
(4,130 Views)
ddeclue@bellsouth.net (Douglas De Clue) wrote in message news:<6f0395b7.0206301531.2ed1589f@posting.google.com>...
> You would need to go through the string one char at a time looking for
> \n \s \t \r etc. and substitute for these non printing characters with
> the "codes" equivalents.
>
> The tricky one to watch out for though will probably be the \
> character which has a "codes" equivalent of \\. You could get stuck
> in an endless loop if you don't code it right.
>
> Douglas De Clue
> LabVIEW developer
> ddeclue@bellsouth.net
>
> rcash wrote in message news:<5065000000080000008E4E0000-1023576873000@exchange.ni.com>...
> > I am trying to convert a string of data from a serial port to it's
> > /codes equivilant. I just want the final string
to be the same thing
> > that you would see in the string indicator if "'/' codes" mode was
> > selected instead of Normal mode. This is the only way I can handle
> > some of the data.

Hi rcash,
there's the possibility of a much simpler solution.
You can programatically change a string control / indicator to display
the \codes, or you can have it permanently set. This is only part of
the solution. You can hide this indicator if you don't want it on your
front panel. So your input comes in (from your serial port), and you
wire it to a string indicator set to \codes. You then need to create a
property node for this indicator, and select Text.Text as the
property. If you look at this (in a normal string indicator, it's
converted it correclty to the \ codes format. I have a quick .vi that
shows this if I've not described it very well here - e-mail me direct.

Sash
0 Kudos
Message 4 of 7
(4,130 Views)

Hi,

 

How would you do the other way around?

 

The below string is a codes representation of an ASCII string. How would I convert it back to ASCII? I want to paste the string as text in another place and be converted as ASCII or HEX.

 

\A8\1B*******\r\n\r\nU\01\A8

0 Kudos
Message 5 of 7
(1,797 Views)

Strings are just byte arrays.  Try to focus on that.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 7
(1,768 Views)

@AleZanBru wrote:

How would you do the other way around?

 

The below string is a codes representation of an ASCII string. How would I convert it back to ASCII? I want to paste the string as text in another place and be converted as ASCII or HEX.

 

\A8\1B*******\r\n\r\nU\01\A8


 

If this string comes from elsewhere and is a normal string in \-codes format and you want it back as its string value, you can use the text.text property, assuming the terminal used for the property node has the correct display style.

 

altenbach_0-1683827611634.png

 

 

If this is not what you want, please be very specific!

 

 

 

0 Kudos
Message 7 of 7
(1,758 Views)