Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6724 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I’ve been struggled with this simple problem and I am sure (or I hope) someone out there has a simple solution.

What I try to do is to remove the space and carriage in the last line of text. I know how to use substitute to remove carriage return, but I have a note field that carriage return is ok unless it is the last line of text. The note field need to convert to html format and the last carriage return (returns) is a pain to deal with.

Thank you for your help.

-JJ

Posted

There are a couple of methods. One of my favorites is the following:

LeftWords(MYTABLE::myfield; 999999999)

The only problem with this approach is any word separator (return, space, period, etc.) not surrounded by a word is removed. For example, let's say you have the following text in your field:

Mary had a little lamb.¶

Not only will the return be removed but so willl the period. However, this solution works great on return-separated lists (like primary keys) because it is easy to implement. If you aren't sure about the data, it is better to use the following formula:

Left(MYTABLE::myfield; Length(MYTABLE::myfield) - 1)

This willl remove the last character. However, it won't remove more than one character or a random number of undesirable characters which gives an advantage to the LeftWords approach.

So, choose the method that best meets your needs.

Posted

Just for preventative maintenance visit the post at the link below. Comment came up with a calculation to remove x number of trailing carriage returns from a field. If you are getting a single trailing carriage return now your users are bound to mistakenly add more later. I know my users do it all the time.

I would copy and paste the calculation for you in this thread but I can no longer copy any text on this forum.

http://fmforums.com/forum/showtopic.php?tid/168001/post/168343/hl/Remove+carriage+return+sbg2/#168343

This topic is 6724 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.