LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String manipulation question

For some reason, I was not able to locate the solution to this.  I'm sure its out there.   I want a simple decimal to ascii conversion for a 2 digit number with zero fill before numbers less than 10.  Here is a solution but I can't imagine there isn't something more straight forward than this.

 

Froboz_0-1662081485699.png

 

I would have thought that after the number to hex conversion I would get a straight answer.  So, assume I entered the number 5, it would become 05 and then in the byte array would be 48 and 53.  After the hex conversion I was thinking I would get 30 and 35, respectively, but instead I get 3330 and 3335.  Hence the need to get the substring to eliminate the first two digits, followed by the concatenation.

 

I'm sure there's got to be an easier way.

0 Kudos
Message 1 of 10
(2,127 Views)

This seems to satisfy your test case

santo_13_0-1662083169054.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 10
(2,118 Views)

Hi Froboz,

 

This seems to do the job:

Test.png

Xonmyth743_1-1662129046884.png

 

I am not sure if this solution would not work for you in a certain scenario.

Message 3 of 10
(2,070 Views)

LV2022-09-02 172458.jpg

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 10
(2,047 Views)

Xonmyth743_0-1662133384975.png

 

0 Kudos
Message 5 of 10
(2,041 Views)

@Froboz wrote:

I'm sure there's got to be an easier way.


The answer quality typically does not exceed the quality of the question, and your definitions are lacking.

For example, "decimal" and "ASCII" are very vague terms that can be interpreted in many different ways.

What is the display style of your final string?

 

Please attach your VI, not a truncated blurry picture .

 

See if this can give you some ideas....

 

altenbach_0-1662134936961.png

 

 

Message 6 of 10
(2,037 Views)

Whether it solves the OPs requirement or not, I am learning different innovative approaches.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 7 of 10
(2,004 Views)

Here is one more:

Xonmyth743_1-1662146214299.png

 

 

0 Kudos
Message 8 of 10
(1,990 Views)

If you take that same concatenated string indicator and change it from normal to hex, this is what I get:  

Froboz_0-1662145747499.png

When I tried this before, buiIding up ascii strings to communicate with a device over TCP, I was getting errors.  

Froboz_1-1662146239096.png

 Without having a scope to corroborate that the wrong data is being sent out, I can only tell indirectly that this form is having issues because I am getting errors from the logging device.  The indicator has to be in the form of hexadecimal and must show 3035, where as the normal form shows something else.

0 Kudos
Message 9 of 10
(1,989 Views)

@Froboz wrote:

The indicator has to be in the form of hexadecimal and must show 3035, where as the normal form shows something else.


Well, that seems to be quite important information (and should have been mentioned from the beginning!)

 

It makes the problem even more trivial (indicator is in hex display now):

 

altenbach_0-1662148646530.png

 


@Froboz wrote:

 

Froboz_1-1662146239096.png

 


You really need to eliminate all ambiguities and attach your code instead of truncated ambiguous pictures.

The display style (normal, hex, etc.) is a purely cosmetic property of the indicator and has nothing to do with the underlying data, so labeling one string wire as "normal" and other wires as "hex" is completely meaningless!

 

Instead of all your red comments, just make it a habit to show the display style of string diagram constants and controls/indicators:

 

altenbach_0-1662149457798.png

 

 

 

 

Message 10 of 10
(1,964 Views)