Jump to content
Server Maintenance This Week. ×

Find Text In Biggest Gap Between Variable


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

Recommended Posts

Is there anyone who could easily figure out how to write a custom function - probably a recursive custom function - which would find the text in the biggest gap between a repeating variable. Say we called the function 'crux', with the parameters, 'text' and 'v',

crux (field ; " - ") would equal "Hello world. How are things?" when field equals "orange - blue - green - red - yellow - Hello world. How are things? - apples - cherries - cranberries"

Link to comment
Share on other sites

I figure using something like my 'btwn' custom function would help in this - http://fmforums.com/forum/index.php/topic/62229-in-between-btwn-text-first-fo-second-so/

I figure using something like my 'btwn' custom function would help in this - http://fmforums.com/forum/index.php/topic/62229-in-between-btwn-text-first-fo-second-so/

I figure using something like my 'btwn' custom function would help in this - http://fmforums.com/forum/index.php/topic/62229-in-between-btwn-text-first-fo-second-so/

Link to comment
Share on other sites

Yes. That's exactly what I mean. If there's a tie, I suppose it should be whichever item comes first.

I could write it non-recursively, but I think it would take too long for filemaker to perform the calculations.

let (a = v & text & v ;

let ([i1= btwn (a ; v ; 1 ; v ; 1) ; i2 = btwn (a ; v ; 2 ; v ; 1); ... i1000 = btwn (a ; v ; 1000 ; v ; 1)];

let (len= max (length (i1) ; length (i2); ... length (i1000) ) ;

case ( length (i1) = len ; i1 ; length (i2) = len ; i2 ; ... length (i1000) = len ; i1000)

)))

Link to comment
Share on other sites

Thanks!

I used that as a subordinate function that does exactly what I wanted:

crux (text ; variable)

If(v=¶ ; LongestValue ( text ) ;

Let (a="apnoeaniorjeoapnfioenapfjoaiiralerlnoiahrafoenai" ;

Substitute(LongestValue(Substitute ( text ; [¶ ; a]; [variable ; ¶])); a ; ¶)))

See if this helps:

http://www.briandunning.com/cf/1244

If your list uses another a different separator, you could call the function as:

LongestValue ( Substitute ( YourList ; YourSeparator ; ¶ ) )

Link to comment
Share on other sites

crux (text ; variable)

If(v=¶ ; LongestValue ( text ) ;

Let (a="apnoeaniorjeoapnfioenapfjoaiiralerlnoiahrafoenai" ;

Substitute(LongestValue(Substitute ( text ; [¶ ; a]; [variable ; ¶])); a ; ¶)))

You got me there - I'm afraid I have no idea what that does. :

Link to comment
Share on other sites

You got me there - I'm afraid I have no idea what that does. :

It should be:

crux (text ; variable)

If(variable=¶ ; LongestValue ( text ) ;

Let (a="apnoeaniorjeoapnfioenapfjoaiiralerlnoiahrafoenai" ;

Substitute(LongestValue(Substitute ( text ; [¶ ; a]; [variable ; ¶])); a ; ¶)))

It's pretty much what you recommended, except it accounts for the possibility (which is common for my purposes) that there will be a ¶ inside of the result that I'm looking to get.

Link to comment
Share on other sites

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