Jump to content

Repeating Sequential Numbers


brightfish

Recommended Posts

I'm sure there's an easy way to do this, but I can't seem to wrap my head around it...

 

I need to produce sets of sequential numbers. I have a series of prefixes (i.e. "R21-") that each have a different starting number (i.e. "2145") and a different number of sequential numbers needed for each prefix. The kicker is that I need each sequential number to repeat a different number of times for each prefix. For example, line item (prefix) 1, may need to repeat each number three times and would output like this:

 

R21-02145

R21-02145

R21-02145

R21-02146

R21-02146

R21-02146

R21-02147

R21-02147

R21-02147

...

 

I'm using the repeatrecordCount call in onRecordStart to specify the quantity of unique numbers for the set. I can't figure out how to get each of those unique numbers to repeat x number of times though.

 

Does that make sense?

Link to comment
Share on other sites

Here's a sample of a few records...

 

(sorry, pasting the data didn't work. Here's a screen cap of it)

 

 

 

The quantity would be the number of unique numbers for that set. The repeat count is the number of times that each of the unique numbers needs to repeat.

 

(Go Tigers this weekend!)

ScreenShot2013-11-26at4_07_23PM.png.18958b86f3601629093170b53b20b213.png

Link to comment
Share on other sites

Well since you are also hoping for a Gamecock loss, I feel like I should probably lend my solution to you ;)

 

First of all, since you are repeating each record by the quantity, and each of those record repeats gets repeated again, you need to set your repeatRecordCount equal to Quantity * Repeat Count.

 

Then you can create an array of ticket values using 2 'for' loops. The first to loop through the "Quantity" and the second (nested) to duplicate that value by the value of the "Repeat Count" field. This will give you a resulting array that is the length of "Quantity" * "Repeat Count".

 

Then you can name the text frame that you want the ticket numbers to show up in (something like "TicketNumber") and populate it from OnRecordStart by accessing the ticket values using the current number of repeats that FP has gone through (FusionPro.Composition.repeatRecordNumber). Remember that array positions start at 0 so you'll have to subtract one from that number.

 

So your OnRecordStart Rule would look something like this:

var tickets = [];

for (var i=0; i<Int(Field("Quantity")); i++){
   for (var n=1; n<=Int(Field("Repeat Count")); n++){
       tickets.push(Field("Prefix-FP") + "-" + (Int(Field("Starting Number")) + i)); 
   }
}

FusionPro.Composition.repeatRecordCount = Int(Field("Quantity")) * Int(Field("Repeat Count"));

FindTextFrame("TicketNumber").content = tickets[FusionPro.Composition.repeatRecordNumber-1];

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...