If it's always two undesired characters appended to the end, why not this expression?
Left ( text ; Length ( text ) - 2 )
The problem with that is sometimes people enter the data into the field manually, so I can't unconditionally truncate the string like that. I can't do it conditionally since Char(0) = <expression that should evaluate to the null character> returns false no matter the contents.
Char (0) returns an empty string--that's why that won't work here.
Out of curiosity, have you confirmed that Code ( <pasted null character ) returns zero?
You might test for the presence of the newline character and only strip the last two characters if the newline character is the last character of the string.
Your custom function could also loop through the text via recursion to test each letter for one where Code() returns zero (or whatever your test shows the value to be.)
Yeah, Code(<pasted null character>) returns 0. The recursive function checking for Code(0) was a good idea -- thanks! I've implemented it as so:
Case ( Length(text) = 0; "";
Code(Left(text; 1)) = 0; "" & FilterNull(Right(text; Length(text)-1));
Left(text; 1) & FilterNull(Right(text; Length(text)-1))
There seems like there should be a better way, though. Maybe I should file a bug report/feature request? Anyway, thanks again.
If you are willing to give up any ending * periods then you can use:
LeftWords ( field ; Length ( field )
This will strip all garbage before and after your text, including carriage returns, tabs, and lower ASCII characters.
* you would lose any beginning or ending word-break characters, such as ()$.- etc and it will not remove any lower ASCII which might be in the middle of the text strings.
Thanks for the idea. It works for the small size text field. How about long text field.
I have tried the idea of using substitute function, seems not working with null value character.
copy from FmDiff.com
Function Name and Parameters:
cleanText ( text )
Substitute ( text ;
[ char ( 0 ) ; "" ] ; // This requires FileMaker Pro 10 or up
[ char ( 1 ) ; "" ] ;
[ char ( 2 ) ; "" ] ;
[ char ( 3 ) ; "" ] ;
[ char ( 4 ) ; "" ] ;
[ char ( 5 ) ; "" ] ;
[ char ( 6 ) ; "" ] ;
[ char ( 7 ) ; "" ] ;
[ char ( 8 ) ; "" ] ;
// char(9) = Tab*
// char(10) = LineFeed*
[ char ( 11 ) ; "" ] ;
[ char ( 12 ) ; "" ] ;
// char(13) = Return*
[ char ( 14 ) ; "" ] ;
[ char ( 15 ) ; "" ] ;
[ char ( 16 ) ; "" ] ;
[ char ( 17 ) ; "" ] ;
[ char ( 18 ) ; "" ] ;
[ char ( 19 ) ; "" ] ;
[ char ( 20 ) ; "" ] ;
[ char ( 21 ) ; "" ] ;
[ char ( 22 ) ; "" ] ;
[ char ( 23 ) ; "" ] ;
[ char ( 24 ) ; "" ] ;
[ char ( 25 ) ; "" ] ;
[ char ( 26 ) ; "" ] ;
[ char ( 27 ) ; "" ] ;
[ char ( 28 ) ; "" ] ;
// char ( 29 ) = Group Separator (see table below)
[ char ( 30 ) ; "" ] ;
[ char ( 31 ) ; "" ]
Have you tried this?
[ Base64Decode("AA==") ; "" ]
Thanks for your suggestion, cannot try this directly on FMP 11. There is no Base64Decode function. No luck on trying this on using baseElement plugin function.
Want to try the suggestion on FMP15, it seems FMP15 is more clever and already trim out the null value from the data entry after copying it from the problem source.
Anyway, thank you for your great suggestion.
I would use the Filter function and list all the characters that I want to keep rather than trying to figure out how to identify and remove all the characters that need to be removed. It can be a long string in the filter function, but avoids a number of these hassles.