March 20, 200124 yr Does anyone know of a way to count the number of lines in a text field. Thank you Lar
March 23, 200124 yr Author 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.
March 23, 200124 yr 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
April 9, 200124 yr 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.
Create an account or sign in to comment