Jump to content
Server Maintenance This Week. ×

Number of lines between two, in a list


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

Recommended Posts

If I have a list (one text field), such as:

Pigs

Can

Fly

Pigs

Don't

[color:blue]Fly

South

For

Winter

[color:green]Pigs

Fly

North

For

Summer

I want to specify two lines (in this case words) and find the number of lines between them. So, if I specify [color:green]Pigs then [color:blue]Fly, I want the result to be determined as:

The last Pigs entry is at 10. The first Fly entry (BEFORE) the last Pigs is at 6. Difference is 4. So the first criteria is the LAST matching entry and the second criteria is the FIRST entry right before the first criteria (last Pigs). My result should be 3 (3 full lines between). I don't have a text field like this. I'm trying to understand how to numberize lists and determine the number of a line within the list in relation to a different line within the same list. I would also like to protect from false positives in case there is more than one word per line.

I'm not using 8.5 yet so I haven't played with the List idea. I'd like to accomplish this in 8.0 but wouldn't mind knowing how 8.5 would handle it as well.

LaRetta

Link to comment
Share on other sites

The first Fly entry (BEFORE) the last Pigs is at 6.

No, the FIRST "Fly" entry before the last "Pigs" is at 3. Assuming you mean the LAST "Fly" entry before the last "Pigs", you could try something like this (untested, no error checking):P

Let ( [

end = Position ( ¶ & text & ¶ ; "¶Pigs¶" ; Length ( text ) + 2 ; - 1 ) ;

short = Left ( text ; end - 2 ) ;

start = Position ( ¶ & short & ¶ ; "¶Fly¶" ; Length ( short ) + 2 ; - 1 ) ;

mid = Middle ( text ; start ; end - start - 1 )

] ;

ValueCount ( mid ) - 1

)

Link to comment
Share on other sites

That works perfectly! I see how you chopped the list using 'short' to grab the last of the first (fly); well actually the LAST fly (in the short). That was my main sticking point. This shows me how to break up lists!! Thanks for listening for my meaning and not just my words. This calc is very clear and the perfect example of extracting anything within ANY string if the parameters are properly specified. I will memorize this puppy.

Very much appreciated, Michael. :smile2:

LaRetta

Link to comment
Share on other sites

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