Jump to content

Issue with Naming Output to Multiple Files


brinehart

Recommended Posts

Having an issue and wasn't sure if there was an elegant way to produce what I need or if even possible.

 

In OnRecordStart I have the code:

if (FieldChanged("Version"))
   FusionPro.Composition.OpenNewOutputFile("160555-1_" + Field("Version") + "_impo + "." + FusionPro.Composition.outputFormatExtension);

 

Normally, this is used to output different files whenever a field changes values. I'm wanting to output files of 4000 records(2up stacks of 2000).

 

When not needing to split files by an amount of records I don't have any issues but trying to have multiple versions and outputting a specific amount of records breaks the naming.

 

The file naming would ideally use the code and name the files:

  • "160555-1_A_impo1"
  • "160555-1_A_impo2"
  • "160555-1_A_impo3"
  • "160555-1_B_impo1"
  • "160555-1_B_impo2"

 

Currently, I'm getting the first file named based on the code in OnRecordStart but every subsequent file is named based on what is input in "Output File:" in Composition Settings until the field changes to something different.

  • "160555-1_A_impo"
  • "160555-1_impo2"
  • "160555-1_impo3"
  • "160555-1_B_impo"
  • "160555-1_impo5"

 

Is there a way to code the rule to output filenames based on data fields AND split files when a field changes?

Link to comment
Share on other sites

So there are two ways in which the output can be broken up, or "chunked," into multiple output files: static chunking and dynamic chunking.

 

Static chunking (the older way) is where each output file (except for possibly the first) has the same (static) number of records, defined on the Output tab of the Composition Settings. The names of the output files are based on the output file name specified in the Composition Settings, with numbers appended, unless a different name is specified in the OnNewOutputFile callback rule.

 

Dynamic chunking (the newer way) is where each output file can have a different (dynamic) number of records. This is done, as you are doing, by calling FusionPro.Composition.OpenNewOutputFile() in OnRecordStart. In this case, the name of the new output file is also based on the output file name specified in the Composition Settings, with numbers appended, a different name is specified in the function call.

 

It sounds like you're doing a hybrid, both kinds of chunking at the same time, which does work, but it can be weird. Sometimes a new output file is triggered by the record number, a multiple of the number specified in the Composition Settings, and somethings it's triggered by the field value changing per your OnRecordStart rule.

 

I don't completely understand what you're trying to accomplish, but I think that you want to tun off the static chunking, by unchecking the "Output to multiple files" box in the Composition Settings, and just use dynamic chunking. Then all the output files you're making will have their names specified by the call to FusionPro.Composition.OpenNewOutputFile().

 

Or, you could continue to use a hybrid of static and dynamic chunking, and create the OnNewOutputFile rule to specify the names of the files being broken up by record numbers.

Link to comment
Share on other sites

Dan, thank you for that info! I guess a little more background information would be helpful.

 

To help press loads and bindery/finishing, the sheet stacks were capped at 2000 sheets which is where the output to 4000 records(2up 2k records) was needed. To help the workflow of prepress, we have merged multiple processed lists into one master list—each group in the list is mailed out separately so they need to stay in separate files regardless of record count. That separation is where the OpenNewOutputFile helps keeps everything separate and named accordingly.

 

I don't believe we've ever needed to have this type of chunking before—either the amount of records wasn't large enough to warrant chucking by record count or there was only one version to output. So, I wasn't sure if there was an easy way to accomplish this task

 

I don't completely understand what you're trying to accomplish, but I think that you want to tun off the static chunking, by unchecking the "Output to multiple files" box in the Composition Settings, and just use dynamic chunking. Then all the output files you're making will have their names specified by the call to FusionPro.Composition.OpenNewOutputFile().

 

Unless I'm missing something here, I think our issue if we turned off "Output to multiple files" is the amount of records for one chunk would be too much in a single file(60k+ records). And having the imposition file as cut and stack would get the records out of order when trimming sheets or splitting the files after composition.

 

Was hoping there was another way of setting up my rules to use the dynamic chunking in a more efficient way that could use the same naming convention and keep files grouped together.

 

Apologies if that explanation wasn't clear!

Link to comment
Share on other sites

Here is something I have done in the past. Maybe this will work for you:

 

Javascript Global

var SetCount = 0
var SubSetCount = 1



If using imposition stacking

OnJobStart

FusionPro.Composition.chunksBreakStacks = true;




OnRecordStart

var JobNumber = "78807 "
var StackSize = 4000
function NewName()
{
FusionPro.Composition.OpenNewOutputFile(JobNumber + Field("Package") + "_" + SubSetCount + "." + FusionPro.Composition.outputFormatExtension);
}

if (FieldChanged("Package"))

   {
       SetCount = 1;
       SubSetCount = 1;
       NewName()
   }

else

   {
       if (SetCount < StackSize)

           {
               SetCount = SetCount + 1;
           }

       else

           {
               SubSetCount = SubSetCount + 1;
               NewName()
               SetCount = 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...