Page 1 of 1

Max int length for ToString$

Posted: Tue Apr 05, 2016 5:39 pm
by GTF
Is there a maximum length that will be converted? If my number is greater than 4 digits, it gets truncated to the first 4.
eg. 12345 converts to 1234

Re: Max int length for ToString$

Posted: Tue Apr 05, 2016 6:13 pm
by kersing
The obvious question first, what is the length of your string?

Re: Max int length for ToString$

Posted: Tue Apr 05, 2016 7:20 pm
by GTF
I created a standard string variable (length 20). I am sending over USB serial.

Re: Max int length for ToString$

Posted: Tue Apr 05, 2016 9:24 pm
by medelec35
Hi Grant,
I have created a ULong assigned it with 1234567890 and no problems sending via UART USB:
Ulong to string via uart to USB converter.png
(178.37 KiB) Downloaded 3386 times
Or in your case Serial USB:
Ulong to string via Serial USB.png
(213.24 KiB) Downloaded 3386 times
Martin

Re: Max int length for ToString$

Posted: Tue Apr 05, 2016 9:48 pm
by GTF
Actually, I think it was a string length issue. I forgot that the variable was concatenated with other strings. The sum length of the strings had grown too long for the holding string[30].

Re: Max int length for ToString$

Posted: Tue Apr 05, 2016 9:59 pm
by medelec35
Did you want to post the flowchart you are having issues with?

Re: Max int length for ToString$

Posted: Wed Apr 06, 2016 2:18 am
by GTF
Turns out it is not a string length issue. It appears to be related to the concatenation itself. This doesn't work(string1[40]), but sending the converted 12345 alone works.

Re: Max int length for ToString$

Posted: Wed Apr 06, 2016 2:44 am
by GTF
This works fine

Re: Max int length for ToString$

Posted: Wed Apr 06, 2016 8:52 am
by LeighM
Hi

You are right, it is string concatenation that causes issues when more than two are concatenated.

This will cause problems (due to an internal bug with the use of a temporary string) ...

Code: Select all

str = str1 + str2 + str3
Instead, do this ...

Code: Select all

str = str1
str = str + str2
str = str + str3
Hope that helps,
Leigh