dbTalk Databases Forums  

Remove extra spaces and line endings

comp.databases.filemaker comp.databases.filemaker


Discuss Remove extra spaces and line endings in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Railman
 
Posts: n/a

Default Remove extra spaces and line endings - 07-11-2005 , 06:47 PM






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


Reply With Quote
  #2  
Old   
Howard Schlossberg
 
Posts: n/a

Default Re: Remove extra spaces and line endings - 07-11-2005 , 07:17 PM






Railman wrote:
Quote:
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
This was just discussed here last week. Please check the archives via
Google.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Howard Schlossberg (818) 883-2846
FM Pro Solutions Los Angeles, California

FileMaker 7 Certified Developer
Associate Member, FileMaker Solutions Alliance


Reply With Quote
  #3  
Old   
Matt Wills
 
Posts: n/a

Default Re: Remove extra spaces and line endings - 07-11-2005 , 08:05 PM



Railman wrote:

Quote:
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
Just to give you an idea what to look for, it's the Trim ( Text )
function. There was a considerable thread that has continued right up to
yesterday.

Matt


Reply With Quote
  #4  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Remove extra spaces and line endings - 07-12-2005 , 01:12 AM



In article <2005071117472516807%railman@sasktelnet>, Railman
<railman (AT) sasktel (DOT) net> wrote:

Quote:
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)


Reply With Quote
  #5  
Old   
eyebrown@mindspring.com
 
Posts: n/a

Default Re: Remove extra spaces and line endings - 07-12-2005 , 06:47 AM




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.

Steve Brown


In article <120720051812447403%helpful_harry (AT) nom (DOT) de.plume.com>, Helpful
Harry <helpful_harry (AT) nom (DOT) de.plume.com> wrote:

Quote:
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)

Reply With Quote
  #6  
Old   
Helpful Harry
 
Posts: n/a

Default Re: Remove extra spaces and line endings - 07-12-2005 , 03:41 PM



In article
<eyebrown-1207050749270001 (AT) 216-10-173-70 (DOT) earthlink.wispnet.net>,
eyebrown (AT) mindspring (DOT) com wrote:

Quote:
Harry:

All those calcs below are lovely, but why jump through so many hoops to
avoid using the Trim function?
The Trim function ONLY removes leading / trailing space characters - it
won't remove any leading / training carriage returns, tabs or other
characters. For all of those you need to use something like Debi Fuchs'
calculation.



Quote:
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.
Once you've got the calculation you can of course use it in various
ways via scripts (perhaps a closing script which uses the calculation
to replace the original field's data when exiting the file), including
automating imported data. Of course, if you going to script it then you
don't really need the calculations at all since you could simply
perform a loop to go through the field removing the extra characters.

BUT there's no way to "automate" user entered data with the extra
characters ... other than continually beating them over the head with a
wet sponge until they learn not to add them. ;o)



Helpful Harry
Hopefully helping harassed humans happily handle handiwork hardships ;o)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.