Jump to content

looping counting limiting script thingy


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

Recommended Posts

  • 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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 7142 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
 Share

×
×
  • Create New...

Important Information

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