キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

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.pngFroboz_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 件の賞賛
メッセージ1/10
3,499件の閲覧回数

This seems to satisfy your test case

santo_13_0-1662083169054.pngsanto_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
0 件の賞賛
メッセージ2/10
3,490件の閲覧回数

Hi Froboz,

 

This seems to do the job:

Test.pngTest.png

Xonmyth743_1-1662129046884.pngXonmyth743_1-1662129046884.png

 

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

メッセージ3/10
3,442件の閲覧回数

LV2022-09-02 172458.jpgLV2022-09-02 172458.jpg

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

Qestit Systems
Certified-LabVIEW-Developer
0 件の賞賛
メッセージ4/10
3,419件の閲覧回数

Xonmyth743_0-1662133384975.pngXonmyth743_0-1662133384975.png

 

0 件の賞賛
メッセージ5/10
3,413件の閲覧回数

@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.pngaltenbach_0-1662134936961.png

 

 

メッセージ6/10
3,409件の閲覧回数

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
0 件の賞賛
メッセージ7/10
3,376件の閲覧回数

Here is one more:

Xonmyth743_1-1662146214299.pngXonmyth743_1-1662146214299.png

 

 

0 件の賞賛
メッセージ8/10
3,362件の閲覧回数

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

Froboz_0-1662145747499.pngFroboz_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.pngFroboz_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 件の賞賛
メッセージ9/10
3,361件の閲覧回数

@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.pngaltenbach_0-1662148646530.png

 


@Froboz wrote:

 

Froboz_1-1662146239096.pngFroboz_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.pngaltenbach_0-1662149457798.png

 

 

 

 

メッセージ10/10
3,336件の閲覧回数