Jump to content

How to compose a range of records?


LeberMac

Recommended Posts

Let's say that, through the course of a normal variable-data newsletter operation, some of the newsletters get mangled in the tabber after another flawless print run out of FusionPro. Or they get crushed in the folder/creaser. Or they get trimmed wrong. So, say in a 1,000-record job, I need to reprint records 2, 345-351, 657, and 987-998.

 

Is there an easy way to print a complex range of records in FusionPro? All I get in the Composition Settings Dialog box for Input is

[ ] ALL; or,

[ ] ____ to ____.

 

As it stands now, if I had the problem in the example above, I'm composing 4 files, one for 2, one for 345-351, one for 657, and one for 987-998, then I'm combining those all into one PDF file for reprinting.

 

I'm thinking that there's GOT to be a better way to do this. I can go back in and edit my source CSV file, and then save it as the "repairs" file, but that's a kludge.

 

I would LOVE to be able to specify a range of records to print, just like printing pages from InDesign or Quark XPress. In a multi-page document, I can specify printing pages: 2, 345-351, 657, 987-998. And it will print JUST those pages.

 

If there's NOT a way to do this currently, can I humbly submit this for a feature request in future versions? (Like 6.1 ?)

 

Thanks!

Link to comment
Share on other sites

I haven't tried to do this, but I think you should be able to do it within an OnRecordStart rule. It would be a pretty conveluded "if-else" statement and combine this a "FusionPro.Composition.composeThisRecord = false;" and you should be able to specify a range that you want. However, it wouldn't be in the actual composition menu, you would have to compose the entire file to do this - or at least enough to cover your range values.

 

FusionPro.Composition.composeThisRecord = false;

 

If (CurrentRecordNumber() == 2) {

...FusionPro.Composition.composeThisRecord = true;

}

else if ((CurrentRecordNumber() >= 345) && (CurrentRecordNumber() <= 351)) {

...FusionPro.Composition.composeThisRecord = true;

}

else if ..... and so on

 

This way you only turn on the value to compose that specific record if it is within your range values in the if statements.

Good Luck

Link to comment
Share on other sites

Heh, thanks, Dave!

 

I suppose I could write a giant if...then loop for every time I have to create a repairs file, but in reality it will be easier to just edit the .csv data file that gets imported. (And then compose JUST the records that need to be reprinted.)

 

So... hey - maybe Printable could put this feature request on the fast track for inclusion in 6.1?

 

... maybe?

 

:D

Link to comment
Share on other sites

I suppose I could write a giant if...then loop for every time I have to create a repairs file, but in reality it will be easier to just edit the .csv data file that gets imported. (And then compose JUST the records that need to be reprinted.)

 

So... hey - maybe Printable could put this feature request on the fast track for inclusion in 6.1?

 

Well, we'll certainly be glad to consider any new feature or enhancement requests, but I can't say what the priority of any given request will be. I'm not sure how many customers would make use of such a feature.

 

FusionPro.Composition.composeThisRecord = false;

 

If (CurrentRecordNumber() == 2) {

...FusionPro.Composition.composeThisRecord = true;

}

else if ((CurrentRecordNumber() >= 345) && (CurrentRecordNumber() <= 351)) {

...FusionPro.Composition.composeThisRecord = true;

}

else if ..... and so on

 

This way you only turn on the value to compose that specific record if it is within your range values in the if statements.

 

That will certainly work, but there are definitely more succinct ways to accomplish this kind of thing in JavaScript. First off, you can certainly replace all those multiple "if/else" blocks with a few uses of the || ("or") operator, like so:

FusionPro.Composition.composeThisRecord = (CurrentRecordNumber() == 2) ||
((CurrentRecordNumber() >= 345) && (CurrentRecordNumber() <= 351)) ||
((CurrentRecordNumber() >= 987) && (CurrentRecordNumber() <= 998));
return FusionPro.Composition.composeThisRecord;

But we can simplify this further by using a local variable, like so:

var val = CurrentRecordNumber();
FusionPro.Composition.composeThisRecord = (val == 2) ||
((val >= 345) && (val <= 351)) ||
((val >= 987) && (val <= 998));
return FusionPro.Composition.composeThisRecord;

HINT: Hitting Ctrl+F in the Rule Editor will bring up a Find/Replace dialog. Or, in FusionPro 6.0, there's a handy "Find..." button you can click.

 

Also, you can use the Building Blocks dialog to iterate through the records and test to make sure that the result is what you want for each record. That's why we're returning the value at the end. You could also use the Print statement to write a message to the log file for each record saying what the result is.

 

Still, this logic can be generalized even further. Consider this:

 
function CheckRanges(val)
{
 switch (val)
 {
   case 2:
   case 657:
   // etc.
     return true;
 }

 switch (true)
 {
   case (val >= 345 && val <= 351):
   case (val >= 987 && val <= 998):
   // etc.
     return true;
 }

 return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;

You can see that adding more ranges is just a matter of adding "case" lines to the appropriate "switch" statement. (I didn't invent the "switch (true)" trick, but it's cool!)

 

But wait, there's more! If you order now, you also get this:

 
var ranges = [ 2, [345,351], 657, [987,998] ];
function CheckRanges(val)
{
 for (var i in ranges)
 {
   if (ranges[i] instanceof Array)
   {
     if (val >= ranges[i][0] && val <= ranges[i][1])
       return true;
   }
   else if (val == ranges[i])
     return true;
 }

 return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;

It can cut open this tin can and still slice through a tomato!

 

Even more succinctly:

 
var ranges = [ 2, [345,351], 657, [987,998] ];
function CheckRanges(val)
{
 for (var i in ranges)
   if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
     return true;
 return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;

So, all you need to do to modify the ranges you want to recompose is to change this single line:

var ranges = [ 7, [15,34], [75,83] ]; //etc.

I can't imagine any enhancement to the GUI that would be any simpler than that.

 

This kind of thing is exactly why we provide a JavaScript-based rules subsystem with hooks into the composition engine, so that you can do whatever job-specific thing you want to do with a few lines of code, instead of us having to implement dozens of custom dialogs to do a small subset of what some customers might want.

Link to comment
Share on other sites

WOW - thanks, Dan!

 

... I'm imagining Dan Korn with a headset mic like Vince from ShamWOW...

"We can't do this all day.. so if you call in the NEXT 20 minutes..." Hehe.

 

And, to answer Dan's question of "I can't imagine any enhancement to the GUI that would be any simpler than that.", I offer you THIS gem:

 

http://i41.tinypic.com/120gkrt.jpg

 

Anyway, that's how I would envision it, in the Compose dialog box. A function like this would be extremely useful when running "repair" lists for, say, when a range of records of a printed mailpiece gets garbled in the diecutter after bring printed.

Link to comment
Share on other sites

... I'm imagining Dan Korn with a headset mic like Vince from ShamWOW...

"We can't do this all day.. so if you call in the NEXT 20 minutes..." Hehe

LOL. Actually, Alex is the one tied down to a headset all day. I'm really NOT supposed to be doing this (working the forums) all day. I'm supposed to be working on development of the product so that you guys can have new features and bug fixes and stuff like that, and so that we can entice even more new customers, all of whom will proceed to call Alex. :)

 

And if I can envision anyone here doing the ShamWOW thing, it would be our Director of Product Management, Mark Hilger. Hi Mark! :D

And, to answer Dan's question of "I can't imagine any enhancement to the GUI that would be any simpler than that.", I offer you THIS gem:

 

http://i41.tinypic.com/120gkrt.jpg

 

Anyway, that's how I would envision it, in the Compose dialog box. A function like this would be extremely useful when running "repair" lists for, say, when a range of records of a printed mailpiece gets garbled in the diecutter after bring printed.

 

Yes, that's a nice enhancement. (And a nice mock-up too!)

 

But my point about exposing scriptable hooks instead of making new GUI elements is that this is just one of literally hundreds of enhancements that we could make to the product by coding up more dialogs, or even modifying existing ones. But there are several disadvantages to that. The main one is that changing the features in the GUI requires changing the dialogs, which we have to do here, and then we have to release a new version. And we have to make the dialogs work right on multiple platforms, which is no small feat. Scriptable components, on the other hand, are easier to add, and they can be built upon by writing new scripts without making a new release of the software.

 

The other problem is that, even with an enhancement like you suggest, it's still somewhat rigid. Sure, you can specify any number of abritrary ranges, but what if you wanted to do something like re-compose every fifth record, or every record where the LastName field starts with M, or every record with a particular graphic? We simply can't anticipate every possible variation that a customer might need in the future and code up another specialized dialog for it. That's why we embed the JavaScript engine, which lets you code up just about any algorithm you'll ever need. Sure, we sometimes need to add new hooks so that more things are scriptable. And of course, we don't want you to have to write a JavaScript rule to do everything, so we do try to keep things nice and WYSIWYG and point-and-clicky where we can, but ultimately scriptability provides the most flexibility. The reason you have a computer is so that you can program it to do exactly what you want it to do. At least that's my perspective as a developer.

Edited by Dan Korn
fixed Mark's title
Link to comment
Share on other sites

  • 2 years later...
Well, we'll certainly be glad to consider any new feature or enhancement requests, but I can't say what the priority of any given request will be. I'm not sure how many customers would make use of such a feature.

 

 

 

That will certainly work, but there are definitely more succinct ways to accomplish this kind of thing in JavaScript. First off, you can certainly replace all those multiple "if/else" blocks with a few uses of the || ("or") operator, like so:

FusionPro.Composition.composeThisRecord = (CurrentRecordNumber() == 2) ||
((CurrentRecordNumber() >= 345) && (CurrentRecordNumber() <= 351)) ||
((CurrentRecordNumber() >= 987) && (CurrentRecordNumber() <= 998));
return FusionPro.Composition.composeThisRecord;

But we can simplify this further by using a local variable, like so:

var val = CurrentRecordNumber();
FusionPro.Composition.composeThisRecord = (val == 2) ||
((val >= 345) && (val <= 351)) ||
((val >= 987) && (val <= 998));
return FusionPro.Composition.composeThisRecord;

HINT: Hitting Ctrl+F in the Rule Editor will bring up a Find/Replace dialog. Or, in FusionPro 6.0, there's a handy "Find..." button you can click.

 

Also, you can use the Building Blocks dialog to iterate through the records and test to make sure that the result is what you want for each record. That's why we're returning the value at the end. You could also use the Print statement to write a message to the log file for each record saying what the result is.

 

Still, this logic can be generalized even further. Consider this:

 
function CheckRanges(val)
{
 switch (val)
 {
   case 2:
   case 657:
   // etc.
     return true;
 }

 switch (true)
 {
   case (val >= 345 && val <= 351):
   case (val >= 987 && val <= 998):
   // etc.
     return true;
 }

 return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;

You can see that adding more ranges is just a matter of adding "case" lines to the appropriate "switch" statement. (I didn't invent the "switch (true)" trick, but it's cool!)

 

But wait, there's more! If you order now, you also get this:

 
var ranges = [ 2, [345,351], 657, [987,998] ];
function CheckRanges(val)
{
 for (var i in ranges)
 {
   if (ranges[i] instanceof Array)
   {
     if (val >= ranges[i][0] && val <= ranges[i][1])
       return true;
   }
   else if (val == ranges[i])
     return true;
 }

 return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;

It can cut open this tin can and still slice through a tomato!

 

Even more succinctly:

 
var ranges = [ 2, [345,351], 657, [987,998] ];
function CheckRanges(val)
{
 for (var i in ranges)
   if (val == ranges[i] || ((ranges[i] instanceof Array) && val >= ranges[i][0] && val <= ranges[i][1]))
     return true;
 return false;
}
FusionPro.Composition.composeThisRecord = CheckRanges(CurrentRecordNumber());
return FusionPro.Composition.composeThisRecord;

So, all you need to do to modify the ranges you want to recompose is to change this single line:

var ranges = [ 7, [15,34], [75,83] ]; //etc.

I can't imagine any enhancement to the GUI that would be any simpler than that.

 

This kind of thing is exactly why we provide a JavaScript-based rules subsystem with hooks into the composition engine, so that you can do whatever job-specific thing you want to do with a few lines of code, instead of us having to implement dozens of custom dialogs to do a small subset of what some customers might want.

 

 

Is it possible to use the above JavaScript to also compose those record ranges as individual files? Or would that be similar to "arbitrary chunking", as described in Post #2 in this thread I previously started?

Link to comment
Share on other sites

Is it possible to use the above JavaScript to also compose those record ranges as individual files?

No, not currently, unless each series has the same number of records.

Or would that be similar to "arbitrary chunking", as described in Post #2 in this thread I previously started?

Yes, this will be possible with the new arbitrary chunking feature in FusionPro 8.

Link to comment
Share on other sites

  • 11 months later...
I was looking for another solution and ran across this post. Any chance this feature has been added that LeberMac showed a sample of? I read the entire post and I understand the point that theres only so many things you can add but I can't imagine this not being a huges selling point to every printer in the variable print business. Almost every print job that involves finishing work results in some waste. I would use this on a daily basis for my reprints. Just throwing this out there from someone in the field.
Link to comment
Share on other sites

No, that feature was not added to the latest version of FP and I don't get the impression from the prior posts that they had/have any intention of doing so.

 

However, with the latest version of the software, you are capable of accomplishing everything discussed in thread - including the arbitrary chunking of reprint records via JavaScript coding.

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