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

looping counting limiting script thingy

Featured Replies

  • Newbies

So I'm new to FMP scripting, and am stumped. Here's my problem: we have a file that holds numerous fields of our products, and we print them out on brochures. The layout is fine if I want to print 4 or 6 items on a page, but when I want to print 5, then I have problems. Specifically, it works if there are 5 fields or less, but if there are 6 or more, all of them print on my brochure. I want to write some sort of script and/or calculation which can count the number of fields and only display the first 5. Have tried variations of If statements with (Count[item] > Int (5), Choose (from Logical functions), Status(CurrentLayoutCount, CurrentLayoutRecord, or CurrentLayoutNumber) as well as those options for CurrentRecordCount, etc. Have tried Sums, and Loops. Can't figure out how to do it, and also can't find anywhere in the "Specify Calculation" section about how to put in a loop of any kind, so am cutting n pasting from the help file & trying to modify that. I'm sure the solution is simple, but I can't see it...

Here are my script scraps:

//non-working

If ( Count (item_broc_item) > Int (5)

item_broc_item = 5)

End If

//non-working

Status ( CurrentFoundCount ) > Int(5)

//non-working

Int (item_itemszs) = (Count(item_itemszs) + 1)

Loop Until

Count (item_itemszs) >= 5

End Loop

//non-working

Count(item_itemszs) =

Int (item_itemszs) = (Count(item_itemszs) + 1)

Count(item_itemszs) =

Loop Until

Count (item_itemszs) >= 5

End Loop

//non-working

Set Field ("item_counter", "1"]

Loop

Set Field ["item_counter", "item_counter+ 1"]

Exit Loop If ["item_counter >= 5"]

End Loop

Any help would be greatly appreciated.

Jonathan

It may be that all you need is to go to Layout mode, double-click on the part label, and specify "page break after every x occurrences."

However, I'm not exactly sure what your goal is. To some extent you can vary the number of records on a page with printing/sliding options, but you can't really control it. You may want to just create different layouts with different font sizes etc. to accommodate different quantities of records.

When you say "numerous fields," I assume you mean records. I don't totally follow your question. First you say it works with 4 or 6, but not with 5; then you say 5 or less works, but not 6 or more. And I don't understand, "if there are 6 or more, all of them print..." As opposed to, what? With less than 6, they don't all print?

Let me ask you this: are you searching for some records before you print? Are you wanting to simply isolate the first 5 records? Because that is easy to script:

(first perform you find...)

If (Status ( CurrentFoundCount ) > 5

. # no need to use Int() with a count

. Exit Script

End If

Go to record 6

Omit Multiple(no dialog, 99999999)

. # some huge number

Hope that helped.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.