# Extract lines of text from field?

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

## Recommended Posts

If I have a field called "items" that contains for example:

Plant

Tree

Grass

Weed

I want to have different calc fields, one each for each line of text in "items" that will extract that line.

field "calc1" = "Plant"

field "calc2" = "Tree"

field "calc3" = "Grass"

field "calc4" = "Weed"

and

field "calc5" = ""

because there is no line 5 of text in "items."

Is something like this even possible?

LR

##### Share on other sites

The following works for a five line text field, where the lines are separated by a carriage return (

##### Share on other sites

I guess what I was trying to drive at with number 5, but did so poorly...

My text field will not ALWAYS have 4 lines of text. Sometimes it might have 5, sometimes 3, sometimes 4.

The above calc...Only works if the last line (4) has a carriage return after it. Otherwise line 4 does not show up in the calc.

LR

##### Share on other sites

Sorry ibiubu

I stand corrected, the formula for the fourth line in a four line field should be:

field "calc4" = Middle(items & "

##### Share on other sites

Thanks for the help...

Three things that I see:

1) Using the above formula, If I have 5 lines of text, the fifth calc field does not pull out the text from line 5 unless line 5 has a carriage return after it.

2) If line 5 DOES have a carriage return after it, then the calc5 field does pull the text out from line 5, but then calc3 all of a sudden does NOT pull the text out for line 3.

3) And just in case the field only contains 4 lines, again, unless a carriage return is placed after line 4, the calc4 does not work.

LR

##### Share on other sites

OK, here is what worked for me...

If(PatternCount(items, "

##### Share on other sites

Never post a text function, unless you tested it

##### Share on other sites

Sorry, did not follow that last post. My final posted solution was copied from my FM file that seems to work.

1) If the only data that exists is a single line in the field "items" then calc1 grabs that line of text.

2) If there are two lines of data in field "items", line one followed by carriage return and line two...then cal1 one grabs the info from line 1 and calc 2 grabs the info from line 2.

3) If there are 4 lines of text seperated by carriage returns in field "items" it still seems to work. calc1, calc2, calc3 and calc4 all grab information from their respective lines frome field "items"

4) And calc5 seems to work if there are 5 lines in field "items." each of my calc fields grab the appropriate information from the associated line in field "items."

So it seems to be working for me. In any case, thank you SO MUCH for your help. There is no way I could have got it to work. That is a a piece of work you came up with there.

LR

##### Share on other sites

The testing phrase referred to my own formulas, I didn't want to criticize yours! Our last posts just crossed one another

##### Share on other sites

The " " symbol can be written as ">=" in calcs or in the forums. There are also symbols available in the instant graemlins just for posting.

##### Share on other sites

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

## Create an account

Register a new account