09-01-2022 08:22 PM
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.
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.
09-01-2022 08:46 PM - edited 09-01-2022 08:47 PM
This seems to satisfy your test case
09-02-2022 09:32 AM
Hi Froboz,
This seems to do the job:
I am not sure if this solution would not work for you in a certain scenario.
09-02-2022 10:25 AM
09-02-2022 10:43 AM
09-02-2022 10:47 AM - edited 09-02-2022 11:09 AM
@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....
09-02-2022 01:25 PM
Whether it solves the OPs requirement or not, I am learning different innovative approaches.
09-02-2022 02:17 PM
Here is one more:
09-02-2022 02:19 PM
If you take that same concatenated string indicator and change it from normal to hex, this is what I get:
When I tried this before, buiIding up ascii strings to communicate with a device over TCP, I was getting errors.
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.
09-02-2022 02:58 PM - edited 09-02-2022 03:12 PM
@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):
@Froboz wrote:
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: