Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Remove trailing CR


tedg
 Share

Recommended Posts

I have a lot of entries (thousands) which have an unwanted carriage return at the end.

 

What is the best way to eliminate these?

Link to comment
Share on other sites

Replace Field Contents [YourTable::YourField; Case (Right (YourTable::YourField; 1 = "¶"; Middle (YourTable::YourField; 1; Length (YourTable::YourField)-1); YourTable::YourField)]

 

 

Then set an auto-enter replace option to nuke them as they're being entered for moving forward.

Link to comment
Share on other sites

An auto enter calculated value on the field with Do not replace existing value...unchecked, along these lines:

 

Let ( [

crRun = "¶¶¶¶¶¶¶¶¶¶" ;

textCR = Self & crRun ;

last = PatternCount ( textCR ; crRun ) ;

pos = Position ( textCR ; crRun ; 1 ; last )

] ;

Left ( textCR ; pos - 1 )

)

 

Note: n carriage returns in 'crRun' will remove up to n-1 carriage returns - always at the end.

 

Will take care of future entries and possible more than 1 CR.

 

For the existing range of records, use this in a Replace Field Content.

Link to comment
Share on other sites

Thank you. I understand both expressions, but not where to apply them.

 

This would go in the replace field in the Find/Replace dialog?

 

... In the Conditional Formatting Formula dialog?

Link to comment
Share on other sites

This would go in the replace field in the Find/Replace dialog?

 

No. This would go in the Replace Field Contents dialog. Check out the Records menu, it's towards the bottom. (Also available as a script step).

 

 

In the Conditional Formatting Formula dialog?

 

I assume this question is about J Wenmeekers' solution in post #3. In which case, again, no. This formula would go in the field definition of your field, itself, on the Options screen. Auto-enter options. Calculated value.

Link to comment
Share on other sites

Thank you both for the help. Unfortunately, neither solution works.

 

The AHunter3 solution is preferred, but that useful Replace Field Contents dialog (thanks) does not recognize the expression, with the “Replace Field Contents []” bits or not.

 

The J Wenmeekers solution does pass the code check, but has no effect. The Do not replace existing value is unchecked.

Link to comment
Share on other sites

that useful Replace Field Contents dialog (thanks) does not recognize the expression

 

 

I made a typo and left out a trailing parenthesis. You may also be doing something wrong, but without precise, unabridged information I can't tell you exactly what.

 

When you invoke Replace Field Contents you should get a window like this:

 

replace1.png

 

You want the bottom option, "Replace with calculated result".

 

When you click the "Specify" button you get a place into which to type a formula. This is the type of formula you would use:

 

 

Case (Right (YourTable::YourField; 1) = "¶"; Middle (YourTable::YourField; 1; Length (YourTable::YourField)-1); YourTable::YourField)

 

 

You should of course use your own table's name not "YourTable" and you should of course use your own field's name, not "YourField".

Link to comment
Share on other sites

Anybody try the Trim command?

 

Yes, but Trim() will remove all leading and trailing spaces, where the OP wants to remove unwanted carriage returns at the end.....

Link to comment
Share on other sites

won't that also remove leading spaces, whereas the OP only wants to strip out carriage returns and only at the end?

Link to comment
Share on other sites

  • 4 weeks later...

I am clearly missing something simple.

 

I have upgraded to FMP 12 Advanced and downloaded Trim4 ().

 

I have tried it, the two solutions mentioned here, and two other "replace field" solutions found elsewhere (including Supertrim). Either there is something about Mac CRs or something I don't know about custom functions or replace field.

 

Just sticking with Trim4 ()...

 

I open File>Manage>Custom Functions...

 

Hit New...

 

Enter "Trim4" in the function name

 

Enter 'text' in the Function Parameters and the plus button

 

Copy Ray's function from

 

http://www.briandunning.com/cf/166

 

... minus the comment header and paste it in the bottom box, and hit okay.

 

Okay again in the CF manager.

 

Now in browse Form, click the field I wish to clean.

 

Select Records>Replace Field Contents...

 

Replace with calculated results

 

From the functions select Trim4 (text)

 

Replace 'text' with the field name by clicking in the list in the upper left.

 

Okay

 

Replace.

 

No effect.

 

I am doing something simple wrong. Can you spot it?

Link to comment
Share on other sites

Solved. Apparently ALL examples were for PeeCees.

 

All I did was substitute char(10) on my Mac and problem solved!

 

Thanks for the help.

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use