![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is there an easy way to remove extra spaces, line endings to make the field look better and conform to the rest of the file. Mac. OS X |
#3
| |||
| |||
|
|
Is there an easy way to remove extra spaces, line endings to make the field look better and conform to the rest of the file. Mac. OS X |
#4
| |||
| |||
|
|
Is there an easy way to remove extra spaces, line endings to make the field look better and conform to the rest of the file. Mac. OS X |
#5
| |||
| |||
|
|
In article <2005071117472516807%railman@sasktelnet>, Railman railman (AT) sasktel (DOT) net> wrote: Is there an easy way to remove extra spaces, line endings to make the field look better and conform to the rest of the file. Mac. OS X There is no way to reformat entered text within the same field the user enters it ... at least not until FileMaker 7 which apparently has some extra formatting features, but I'm not sure how those work. But you can use a second Calculation field to reformat the data for use on other layouts. Here's a version for FileMaker 7 and older. Note: Unfortunately, thanks to code-mangling by text-based forums, I'm not exactly sure what all the whitespace characters the Substitute function(s) at the beginning is meant to be removing. Substitute( text; [ "*"; "" ]; Space [ " "; "" ]; ??? [ " *"; "" ]; Tab [ "¶"; "" ] Carriage Return ); Obviously this can easily be modified to remove whatever characters you want it to anyway. FILEMAKER 7 ----------- This calculation is by Debi Fuchs from the Cleveland Consulting support (www.clevelandconsulting.com) if you're using FileMaker 7. // Supertrim( Text ) // ====================================== // Remove any leading and trailing whitespace from a string of text Let( [ // Determine result of removing ALL whitespace. t2 = Substitute( Text; [ "*"; "" ]; [ " "; "" ]; [ " *"; "" ]; [ "¶"; "" ] ); // Find position of first non-ws character in original text. first_char = Position( Text; Left( t2; 1 ); 0; 1 ); // Find position of last non-ws character in original text. last_char = Position( Text; Right( t2; 1 ); Length( Text ); -1 ) ]; // If any non-whitespace characters exist, then return // appropriate substring of original text. Case( first_char; Middle( Text; first_char; last_char - first_char + 1 ) ) ) OLDER FILEMAKER VERSIONS (should also work in FileMaker 7) ------------------------ Squashing Debi Fuhs' method above into one older version calculation gives the long-winded looking: TrimmedText {Calculation, Text Result} = If( Position(Text, Left(Substitute(Substitute(Substitute( Substitute(Text, "*", ""), " ", ""), " ", ""), "¶", ""), 1), 0, 1) = 1, Middle(Text, Position(Text, Left(Substitute(Substitute( Substitute(Substitute(Text, "*", ""), " ", ""), " ", ""), "¶", ""), 1), 0, 1), Position(Text, Right( Substitute(Substitute(Substitute(Substitute(Text, "*", ""), " ", ""), " ", ""), "¶", ""), 1), Length(Text), -1) - Position(Text, Left(Substitute(Substitute( Substitute(Substitute(Text, "*", ""), " ", ""), " ", ""), "¶", ""), 1), 0, 1) + 1), ******** "") WHEW! Helpful Harry Hopefully helping harassed humans happily handle handiwork hardships ;o) |
#6
| |||
| |||
|
|
Harry: All those calcs below are lovely, but why jump through so many hoops to avoid using the Trim function? |
|
Incidentally, once you have a suitable calc, instead of saddling yourself with a caloc field that is always the one that contains your real data, why not just run a replace with calculation on the original field? Stamp out the white space one time and be done with it. If new incoming data always has white space, this can be automated. Import the new stuff, your file now has a found set of what was just imported, run the replace. Make it part of the import script and you'll never know it's happening. |
![]() |
| Thread Tools | |
| Display Modes | |
| |