Several problems with text functions - TRIM, LENGTH

According to the site documentation, TRIM removes both leading and trailing spaces. I agree it removes trailing spaces, but it does not appear to remove leading spaces. For example, in the output below, the key of the record where the description is "Mc Tidy Ltdxx" was saved, despite passing the length validity check on the key where it is supposed to be only 5 characters long - it has many leading spaces (and that is why it is not actually a duplicate key of the other record). And that is despite going through the trim function which should have trimmed off the leading spaces in the first place. Am I missing something with both of these? Is there a general problem with string functions? I'm using Memu as the emulator which it says is Android 9 and I've also been testing it on Android 11 on my real phone.

What happens if you use Do it?

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Ok, will check that out. Thanks

with five spaces preceding 'five' and five following it in the TextBox

trim

seems to remove all leading spaces and following spaces. :wink:
five spaces plus 'five' plus 5 spaces = 14

and becomes four characters long when displayed in Label6.
trim2

I see brackets around where you show your leading spaces, indicating automatic JSON conversion of a table crammed into a text display.

Yet you do not show any table handling in your code sample, only handling some display component contents.

You are doing your trimming downstream of where the data lives.

1 Like