07-12-2012 03:02 PM - edited 07-12-2012 03:05 PM
So the issue I am having is that I convert an integer to string using type cast. It gives me the string in ASCII, but unfortunately the type cast function maintains unused integer space resulting in extra characters in my string. I tried changing the integer representation to byte but I quickly realized that I would not be able to have multiple characters. I need a way to remove the extra characters, but if the integer is high enough make another. The situation is like this byte array:
0 0 0 24 0 6 127 254
Think of it as a base 256 counting system that I want to convert it to. I don't want all those leading zeros just like I wouldn't want e.g. 00000433 in base 10, but I want to have the ability to go to e.g. 1433 when the integer is high enough.
Pictures of my block diagram and front panel results are attached.
Solved! Go to Solution.
07-12-2012 03:48 PM
Use the string function "Search and Replace String" to replace the nulls with empty strings. Be sure to wire a True to the "replace all" input.
07-12-2012 03:51 PM
@paul_a_cardinale wrote:
Use the string function "Search and Replace String" to replace the nulls with empty strings. Be sure to wire a True to the "replace all" input.
THis will not work since it will remove ALL NULL bytes and NULLs are valid if surrounded by valid numbers. He only wants to remove leading NULLs. I would search the resulting string for the first non-NULL character and split the string at that point.
07-12-2012 03:55 PM
I'll neglect negative values for the moment.
07-12-2012 04:31 PM - edited 07-12-2012 04:35 PM
@Mark_Yedinak wrote:
@paul_a_cardinale wrote:
Use the string function "Search and Replace String" to replace the nulls with empty strings. Be sure to wire a True to the "replace all" input.
This will not work since it will remove ALL NULL bytes and NULLs are valid if surrounded by valid numbers. He only wants to remove leading NULLs. I would search the resulting string for the first non-NULL character and split the string at that point.
Yes, you are right Mark. Although, I don't know how to find the first character not equal to the NULLS because it may be different everytime. I did come up with a solution, but it's more complicated than I like. Oh well, can't win them all. Thank you for your support.
07-12-2012 04:34 PM - edited 07-12-2012 04:42 PM
@Darin.K wrote:
I'll neglect negative values for the moment.
That is fine. I think your solution is better than mine, as I have discovered mine excludes a few values. Thank you for the time you put into this.