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.

Comparing Length ( field ) for three fields

Featured Replies

So this is kind of simple, but I can't make it work: I have three fields that I want to be filled according to number of characters: field 1 gets the largest number of characters and field 3 gets the smallest.

I have a script that works for fields 1 and 3, but the middle-value field won't work.

To fill fields 1 and 3, I'm saying

If [Length ( db::sourceField2 ) > Length ( db::sourceField1 ) and Length ( db::sourceField3 )]

Set Field [db::fieldText1; db::sourceField2]

Else If [Length ( db::sourceField3 ) > Length ( db::sourceField1 ) and Length ( db::sourceField2 )]

Set Field [db::fieldText1; db::sourceField3]

Else

Set Field [db::fieldText1; db::sourceField1]

End If

To fill field 2, I can see that I need to choose either the middle length or the source field that hasn't been used yet. But FM doesn't seem to like long expressions of greater thans and less thans

(e.g. I tried, if length(sourceField1 ) > length(sourceField2 ) > length(sourceField3 ),

If [Length ( db::sourceField1 ) > Length (db::sourceField2 ) and Length ( sourceField2 ) > Length ( sourceField3 )

and I also tried

If [Length ( sourceField1 ) > Length ( sourceField2 ) and Length ( sourceField3 ) and

Length ( sourceField3 ) < Length ( sourceField1 ) and Length (sourceField2 )

to no avail)

and I can't think of a way that works to choose the unused source field. Variables? My idea of

If [db::fieldText1 = db::sourceField1 (x)or db::sourceField2 and db::fieldText3 = db::sourceField2 (x)or db::sourceField1]

Set Field [db::fieldText2; db::sourceField3]

Else If ~

Else

Set Field [db::fieldText2; db::sourceField2]

End If

didn't work. Oddly enough, either of the two above approaches fills the middle field with the smallest-length field.

I've been spinning my wheels, so I hoped someone would see a clear solution.

Thanks!

How about

f1=

Case(

Length(s1)>Length(s2) and Length(s1)>Length(s3); s1;

Length(s2)>Length(s1) and Length(s2)>Length(s3); s2;

Length(s3)>Length(s2) and Length(s3)>Length(s1); s3;

)

f2=

Case(

Length(s1)>Length(s2) and Length(s1)<Length(s3); s1;

Length(s1)<Length(s2) and Length(s1)>Length(s3); s1;

Length(s2)>Length(s1) and Length(s2)<Length(s3); s2;

Length(s2)<Length(s1) and Length(s2)>Length(s3); s2;

Length(s3)>Length(s2) and Length(s3)<Length(s1); s3;

Length(s3)<Length(s2) and Length(s3)>Length(s1); s3;

)

f3=

Case(

Length(s1)<Length(s2) and Length(s1)<Length(s3); s1;

Length(s2)<Length(s1) and Length(s2)<Length(s3); s2;

Length(s3)<Length(s2) and Length(s3)<Length(s1); s3;

)

Oops, that fails if two sources are the same length.

So this is kind of simple, but I can't make it work: I have three fields that I want to be filled according to number of characters: field 1 gets the largest number of characters and field 3 gets the smallest.

For what purpose?

  • Author

Oops, that fails if two sources are the same length.

Thanks! I can work with that!

For what purpose?

A bunch of people submitted a bunch of comments for a bunch of files. I have a layout that has to fit that info and more on a page in a portal. I could save space if I had just one big text box for the longest comments rather than three big ones with a lot of white space in between.

A bunch of people submitted a bunch of comments for a bunch of files.

OK, that would be a bunch of records, right? Which could be sorted by the Length field? Although I am not sure what you mean by "a page in a portal"; why can't you have one big text box for all the comments, using the List() function?

  • Author

OK, that would be a bunch of records, right? Which could be sorted by the Length field? Although I am not sure what you mean by "a page in a portal"; why can't you have one big text box for all the comments, using the List() function?

Well, because I didn't know about the List() fcn. :) That's a much more elegant approach! :D

And yes, they're really records; the records correspond to application files, hence the slip.

And I mean, since there are actually ≤12 comments (with two groups of three, which are the ones I was trying to work with here) * ≤3 reviewers for every record, I need to have a portal big enough to accomodate all that, so the portal takes up most of a page. I want a record (corresp. to an application + all its comments) to span no more than a page, hence my need to condense all the comments.

I hope that makes more sense now and thanks for the suggestion! :thumbup:

I want a record (corresp. to an application + all its comments) to span no more than a page,

Are you referring to printing or on-screen viewing?

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.