gbenic Posted January 19, 2003 Posted January 19, 2003 Is there a way to calculate how many lines of text there is in a field Thank you
LiveOak Posted January 19, 2003 Posted January 19, 2003 Only if line are defined as ending with a carriage return. Then you can count carriage returns. There is still a plus or minus one line problem if the last lined doesn't end in a carriage return. If lines are defined by text wrap, the number of lines depends upon the the size of the field on the layout. In this case, you can only determine the number of lines if you use a monospaced font (like courier) and know the number of characters in a line. Then you can calculate the number of lines as Total Characters/No. of Characters per Line. -bd
BobWeaver Posted January 19, 2003 Posted January 19, 2003 If your field can contain any arbitrary font and style, and you want to get really carried away, you can use preview mode to automatically estimate the number of lines in the field. What you do is make a new layout with a really big header and footer so that the body part is only 3 lines long. Place a copy of the text field on this layout. When you want to find out how many lines in the field you have a script that: goes to this new layout, enters preview mode, goes to the last page and sees what the page number is. Multiply the page number by the number of lines per page (3 in this case) and you now have the line count accurate to within 3 lines. Why not make the body part only one line long, and then, you could get the count exactly? Because Filemaker starts to puke when the body part gets that small. But, I've had consistent and reliable results, with a body part of 3 lines or more. And you can still get the exact line count by adding a few extra steps to the script. I have attached a sample file that demonstrates the technique. But be warned, this technique may not be robust enough to deploy as part of a commercial solution. I tested it with FM 5.5 on Mac OS9.2. There is a good possibility that it could fail with newer or older versions of Filemaker. And I can guarantee that it will behave differently between Mac OS9, OSX and Windows. Which means that you will have to tweak the 'working preview' layout and/or the script somewhat to make it work with these other platforms. LineCount.fp5.zip
Recommended Posts
This topic is 8049 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 accountSign in
Already have an account? Sign in here.
Sign In Now