# Sequential Number Print

## Recommended Posts

Ok. I have exhausted the search feature and I can't seem to figure out how to accomplish this without doing it manually with a spreadsheet.

I have a project where the job prints a sequential number starting at 1001 and ends at 1251. Then it will start again but the start number is 2001 to 2251 and so on till the last batch at 70001 to 70251. I know I can do this manually but I was trying to find a way to program it to print a batch then increment the next batch by 1000 and this would create the new start number in the sequence till it hits the last batch number.

##### Share on other sites

Someone else can probably post a cleaner way to do this, but I think this would work for you:

```var chunkHeight = 251; // Number in a chunk
var rec = FusionPro.Composition.inputRecordNumber;
var batch = (rec%chunkHeight == 0) ? Math.floor(rec/chunkHeight) : Math.floor(rec/chunkHeight) + 1;
var chunkSeq = (rec%chunkHeight == 0) ? chunkHeight : rec%chunkHeight;

// Format chunkSeq and prepend batch number
var seq = batch + FormatNumber("000",chunkSeq);

return seq;
```

Edited by step
##### Share on other sites

WOW, that works. Only thing is how to format the first 9 batches to have a leading zero like 01001 and 02001 and 03001 etc. till it hits 10001? Edited by Gearstudios
##### Share on other sites

Edit the 'var seq' line to look like this:

```var seq = FormatNumber("00",batch) + FormatNumber("000",chunkSeq);
```

##### Share on other sites

Thanks! That worked perfect.

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×

• #### FusionPro.com

• MarcomCentral
×
• Create New...