Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Find Text In Biggest Gap Between Variable

Featured Replies

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"

  • Author

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/

find the text in the biggest gap between a repeating variable

Just to make sure I understand this: do you mean return the longest item in a variable-separated list of items?

And if so, what should happen in case of a tie?

  • Author

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)

)))

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 ; ¶ ) )

  • Author

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 ; ¶ ) )

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. :

  • Author

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.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.