6 Replies Latest reply on Apr 8, 2014 2:16 PM by bokenrosie

    Trim() is not trimming

    bokenrosie

      Title

      Trim() is not trimming

      Post

           I have Trim(TextFormatRemove(Self )) set as autocalculate on field with the "do not replace..." unchecked.

           It is removing formatting just fine but the trim function is not working.  I can go in and add spaces to end of value and they persist after I leave and come back to that field.

           Any thoughts?  Do I need to break up the functions?

        • 1. Re: Trim() is not trimming
          philmodjunk

               When I tested this, it worked find for me. (If it hadn't, we'd have a bug to report.)

               Trim removes leading and trailing spaces, but not spaces between other characters.

               Trim only removes spaces, not other non visible characters such as space or tab.

               Modifying or adding an auto-enter calculation for an existing field will not produce an automatic update of an existing value in an existing record. You'll see the new calculation affecting results only in new records or in existing records where you modify the value of a field referenced in the calculation.

               Thus, you may be pasting text into your field that contains invisible characters that are not spaces in which case, you might consider including the Filter function to filter out all non visible characters or you may be expecting existing fields to update now that you have added or changed the auto-enter calculation in which case, see this thread for a way to get them to update: Updating values in auto-enter calc fields without using Replace Field Contents.

          • 2. Re: Trim() is not trimming
            bokenrosie

                 It must have been those other invisible characters.

                 I had two fields that I was comparing.  One had just the trim() while the other had the Trim(TextFormatRemove(Self )) piece in there.  It seems like the first one worked reliably and the second did not.

            I just manually removed everything and then tested with spaces at the end of the field and it works as intended.  

            I fear my next question is going to be "how to I see what the invisible characters are" but I guess I'll cross that bridge when I get there.

            Thanks for the clarification.

            • 3. Re: Trim() is not trimming
              philmodjunk

                   That's why I suggested using the filter function. With it, you list the characters you want to keep instead of the characters you want to remove.

                   You might use: Trim ( TextFormatRemove ( Filter ( self ; "abcdefghijilmnopqrstuvwxyz " & Upper ( "abcdefghijilmnopqrstuvwxyz") ) ) )

                   Note that there's a space after the first "z" so that spaces are not filtered out, only trimmed.

                   If numeric digits are permitted, you need to add them, also punctuation characters--especially the ' character may also need to be added.

              • 4. Re: Trim() is not trimming
                bokenrosie

                     That might even work better.  I neglected to mention that I was storing an email address so I found out right away that I had to add @ and - and . to the list of allowed characters.  I assume I only added it for the implied lower part.

                      

                • 5. Re: Trim() is not trimming
                  philmodjunk

                       FIlter is case sensitive and I used the UPPER function so that I could copy and paste the lower case alphabet without having to type the letters all over again with the caps lock down. Other characters that do not have upper and lower case forms do not need to be listed inside the Upper () function.

                       And since this is an email address, I'd remove the space character and the trim function as internal spaces make for invalid email addresses anyway.

                  • 6. Re: Trim() is not trimming
                    bokenrosie

                         Thanks.  I also put back the "k" that you misstyped.  I'm glad I'm not the only guy out here with bad fingers. :)

                         I've often said I owe you a beer.  At the rate I'm going we're up to a case now.