Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displayng a specific line in a text field

Status
Not open for further replies.

justine92

Technical User
May 7, 2012
4
0
0
US
Hi --

I'm fairly new to crystal report development. I have a report that requires to display line 4 of an existing text field. Is there a formula that will allow you to show a specific line from a text field? There would be no blank lines in this case.

Any help would be great!
 
You could try a formula like this:

stringvar array x := split({table.text},chr(13));
if ubound(x)>=4 then
x[4]

-LB
 
I tried the formula but it didn't work. But, I took the formula and changed it to:

stringvar array x := split({TW_V_COMMENTS.TEXT},chr(13)); ubound(x)>=4

which, this showed a 'true' 'false' display, indicating that there was data on line 4.

Is there a function that can be included in the formula that would display the actual value instead of the true/false?

 
What did you see when you used my formula? In what way did it not work?

Please show the values of a couple of text fields and the corresponding formula results to illustrate what is going on.

-LB
 
Thanks, BTW, for your reply.

When I used the formula you sent me, the report showed a blank space where I dropped the formula in the design tab. So, I changed it the formula I referenced above, and it gave me a true/false value instead (meaning, 'true' if there was value on line 4 and 'false' if there wasn't).

So, the text field I'm using has this information in it as an example:

Site Name
Department Name
Department Area
San Jose
Costa Rica

I need the report to print line 4 which will give me the city name. Is this possible to write in a formula?

I appreciate your help! Thanks!
 
My formula should have worked, unless the text isn't using chr(13) for line breaks.

Please add a test formula and let me know the results:

instr({table.text},chr(13))<>0

If the answer is false, then substitute chr(10) (line feed) for chr(13).

Also please verify whether the text is single-spaced. If there were two returns at the end of a line, you would get the incorrect results.

The other test that would help would be if you provide sample text and then add the formula and substitute numbers for the subscript, e.g., replace 4 with 3 in two places and then report back (repeat with other numbers):

stringvar array x := split({table.text},chr(13));
if ubound(x)>=3 then
x[3]

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top