Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

truncating a field to a certain number of words...

Featured Replies

Hi

I'm working on a FileMaker based content management system.

Users post their updates into the system and they appear on the web.

I'm trying to make a field so that it shows the first 90 or so words of an update, so that I can do a PHP include to it on the front page.

When users make an update, certain users can post HTML in theirs.

In my synopsis field, I've tried the LeftWords function and the MiddleWords function and both seem to produce the desired effect.

Apart from...

Where a user has put html in the opening line of their update

For example


<img src="http://imagelocation" alt="" border="0" align="right" />rest of update follows on from here

Then the opening < gets cut off from the synopsis field by both LeftWords and MiddleWords.

Obviously then the image doesn't display properly.

Is there a way to get this to work in a calculation but witout the clipping of the opening '<' character??

Why does the opening '<' character get cut off?

If there's text in front of the opening '<' then it works.

Any ideas?

Batfastad

  • Author

Even if I go like this in my synopsis field...


MiddleWords(



Middle( UPDATE TEXT, 0, 20000)



 , 0, 80)

The leading '<' still gets cut off

Any ideas?

Thanks

Ben

How about


Case( Left( UPDATE TEXT, 1) = "<" , "<" ) & 

[YOUR ORIGINAL CALC]

J

  • Author

Excellent!!

That'll fix it.

Any idea why the LeftWords and MiddleWords functions clip off the leading '<'?

Thanks QuinTech!!!

Ben

FM just doesn't recognize < as a word, that's all. Which makes sense from an English perspective, if not an html perspective.

J

In case your text ends with a closing carat or you just want to be safe, you could also use something like

Substitute( Substitute( MiddleWords( Substitute( Substitute( UPDATE TEXT, "<", "YYYY" ), ">", "ZZZZ" ), 0, 80 ), "YYYY", "<" ), "ZZZZ", ">" )

  • Author

Excellent.

Thanks for all your help guys.

Ben

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.