Jump to content
Server Maintenance This Week. ×

Crop Text w/ Ellipsis?


satone

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

Recommended Posts

Because most display fonts are now proportional there is no easy method to get the amount of the text that will fit into a given space. All that we can work with is the actual character count which is returned by the Length() function.

So, create a calculation field that truncates the text after a number of characters and adds the ellipsis.

Case( Length( text ) > XX ; Left( text ; XX ) & "..." ; text )

Link to comment
Share on other sites

Thanks very much! One quick newbie question tho... where do I put this calculation?

Btw I created a portal for this info in Layout View of the destination table... therefore, I cannot actually see this particular field in the Manage Databases view. Will gladly undo that if needed. :)

Link to comment
Share on other sites

Why does the solution using a conditionally formatted text box require a monospaced font while the one using a calculation field does not?

The text is going to get cut off anyway, there's no need for a calculated field to do it for you.

You don't even need conditional formatting if the text is always larger than the field. It's unclear if the text is ever shorter than the box size.

Link to comment
Share on other sites

Look at this examle:

The field contains: "conditionally formatted" in one row and "require a monospaced font" in another row, but we need to dispay only 16 chars

conditionally fo

require a monosp

where do you put the ellipsis ?

On the contrary the calculted field could solve easily the problem.

Link to comment
Share on other sites

OK so I tried the new calc field. I must have done something wrong b/c it's not truncating...

Here's what I want to do:

Goal: In the Destination table, look at the NOTES field from the Related table. Copy the text, truncate at 52 characters, and add an ellipsis.

Here's what I did:

1: Create a new Calc field in the Related table called NOTES TRUNCATED:

Case( Length( NOTES ) > 52 ; Left( NOTES ; 52 ) & "..." ; NOTES )

2: Reroute NOTES portal in the Destination table to look at the new field NOTES TRUNCATED in the related table.

Here's what is happening...

The NOTES field on the Destination table is, in fact, displaying the NOTES field from the Related table. So something must be going right.....

But it is def not truncating. :/

Any thoughts?

DJ -- the Notes field does not always exceed 52 characters... in fact it's often empty.

Link to comment
Share on other sites

Hmmmm....

Tried that, but still not truncating.

Destination table: SUMMARY

Related table: QUESTION TO SOLUTION

In the NOTES field of SUMMARY:

Case( Length( question to solution::Notes ) > 52 ; Left( question to solution::Notes ; 52 ) & "..." ; question to solution::Notes )

Is there some other setting I have to change or something?

Link to comment
Share on other sites

Destination table: SUMMARY

Related table: QUESTION TO SOLUTION

In the NOTES field of SUMMARY:

Case( Length( question to solution::Notes ) > 52 ; Left( question to solution::Notes ; 52 ) & "..." ; question to solution::Notes )

Your new field should be in QUESTION TO SOLUTION not in SUMMARY.

Or you could do it this way:

mysandbox.fp7.zip

Link to comment
Share on other sites

Thanks for all your help!!

comment and DJ, thanks for the examples. They helped me figure out exactly what I was doing wrong.

I'd like to reply directly to some of your comments, but I can't figure out how to do the cool quote thing. (Newbie to message boards as well as FileMaker :unsure: ) Pls help!

Link to comment
Share on other sites

but I can't figure out how to do the cool quote thing. (Newbie to message boards as well as FileMaker :unsure: ) Pls help!

Use the Reply button that is just below the Post, not the Add Reply under the post.

Link to comment
Share on other sites

Your new field should be in QUESTION TO SOLUTION not in SUMMARY.

Or you could do it this way:

Thanks DJ, your solution was interesting b/c I can edit the NOTES field in the SUMMARY layout. With a Calc field in the SUMMARY layout, I don't seem to be able to edit the notes, just read them.

It does seem strange that you can't truncate exactly. I get that it's easier with a monospaced font. But even with a variable width font, it would seem not that hard. I mean, the program already knows how wide each letter is. Is there a way to just tell it what font you're going to use, and say, "truncate at 10 cm" or whatever? That way, if you type "lol" it know how much space to use and if you type "www" it knows how much space to use.

Just a thought.

Link to comment
Share on other sites

Your description is somewhat confusing. Assuming you have a portal into the Related table placed on a layout of Destinations, all you need to do is to place the calculation field in the portal instead of the Notes field.

Yeah, I get it now... thanks to your example.

The problem was, back before I had discovered the magic of portals, I tried using a regular old lookup field. Then, when I went back to try to implement the calc field as you guys suggested, I accidentally rerouted that to look at the truncated notes calc, rather than the active portal.

Anyway, thanks for your help!!!

Quick question to make sure I'm using the terms right....

Destination table: the place where you want the text displayed (also called a child table?)

Related table: the table that's storing the text (also called a parent table?)

Link to comment
Share on other sites

the program already knows how wide each letter is.

Actually, it doesn't. Al least not at the data level, where the calculation must take place.The rendering of the layout is done "on-the-fly" and depends on a lot of external parameters (OS and font). For example, you could get different spacing just by replacing your Helvetica font with a third party Helvetica font.

Destination table: the place where you want the text displayed (also called a child table?)

Related table: the table that's storing the text (also called a parent table?)

I think you have it backwards: a portal shows records from the child (many) table. The portal sits on a layout of the parent (one) table.

Link to comment
Share on other sites

Actually, it doesn't. Al least not at the data level, where the calculation must take place.The rendering of the layout is done "on-the-fly" and depends on a lot of external parameters (OS and font). For example, you could get different spacing just by replacing your Helvetica font with a third party Helvetica font.

I think you have it backwards: a portal shows records from the child (many) table. The portal sits on a layout of the parent (one) table.

Oh I see. That makes sense.

So Destination table = parent table and Related table = child table?

Link to comment
Share on other sites

So Destination table = parent table and Related table = child table?

LOL, I don't know - those terms mean nothing to me. A child is related to parent and parent is related to child. I suggest you name your tables by what a record represents, e.g. Customers, Invoices, Questions, Answers, etc. Then when you say 'one customer has many invoices' or 'a question can have many answers' the relationship becomes clear.

Link to comment
Share on other sites

This topic is 4833 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.