Jump to content

Counting the number of lines?


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

Recommended Posts

Thanks to your response to my query Steven, you say use the pattern count function to find the carriage return character, what would happen if the lines of text do not contain any carriage returns, the field is like the contents of a letter, that the user just types into, therefore the text just flows from one line to the next - can you think of any way of doing this?

Thanks again for you help

Lar.

Link to comment
Share on other sites

If "lines" are defined by formatting, they really can't be counted easily. The number of "lines" could be different for every layout and font. For proportional fonts, they would not even contain the same number of characters. If a non-proportional font (like Courier) is used, the number of lines is the size of the text field divided by the number of characters per line on the layout (assuming the user doesn't embed carriage returns).

-bd

Link to comment
Share on other sites

  • 3 weeks later...

A somewhat roundabout way to count lines is to make a new blank layout and put an exact copy of your field into it. At least, the width should be exactly the same. The field height should be big enough to display the maximum number of lines that you will ever have. The layout should have a body and footer only. Size the body part so that it is exactly the same height as the field (or just a tiny bit higher). Now increase the size of the footer until a bunch of page breaks appear in the body part. Keep adjusting the footer size until the body part has as many page breaks as there are lines in the field. Set the field's sliding/printing options to slide up and shrink the enclosing part. Now, if you go to browse mode, omit all but the current record, then go to preview mode and then go to last page, the page number of the last page will be equal to the number of lines in the field.

The idea, of course, is to script it like so:

Enter Browse Mode

# Omit all but the current record

Show all records

Omit Record

Show Omitted

# Go to the layout described above

Go to Layout [TestLayout]

Enter Preview Mode

# See how many pages

Go to Record/Request/Page [Last]

Set Field [gLineCount, Status(CurrentPageNumber)]

Enter Browse mode

Go to Layout [original]

This technique, or variations of it, can be used in situations where you want to automagically select the appropriate layout (or field) depending on how the text will be displayed.

Link to comment
Share on other sites

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