PDA

View Full Version : Naming output file


mclisa81
December 13th, 2013, 06:58 AM
I have a rule that names my output files that I need some help with so it works correctly. I'm uploading my files for clarity if needed.

FusionPro.Composition.outputFileName = "ITEMNAME_" + CurrentRecordNumber() + "_" + "codes_" + Field("Codes") + "_thru_" + Field("codeend") + "." + FusionPro.Composition.outputFormatExtension;

1) The CurrentRecordNumber needs to be changed to number the output files sequentially 1, 2, 3, etc.
2) I want to eliminate the Field "codeend" (which I put in manually each time) and use only the Field "Codes" to pull in the ending code # of each batch.

Assuming for this example, I'm composing 23 records in batches of 10. My rule names the output...

ITEMNAME_1_codes_X43c_thru_My1x.pdf
ITEMNAME_11_codes_eX92_thru_P9Mt.pdf
ITEMNAME_21_codes_w6MZ_thru_Z7e1.pdf

What I'd like the files to be named, using only the Field "Codes" are...

ITEMNAME_1_codes_X43c_thru_My1x.pdf
ITEMNAME_2_codes_eX92_thru_P9Mt.pdf
ITEMNAME_3_codes_w6MZ_thru_Z7e1.pdf

Thanks in advance.
Lisa

step
December 13th, 2013, 08:26 AM
Would this work for you?

var input = new ExternalDataFileEx(FusionPro.Composition.inputFile Name,"\t");
var codeEnd = input.GetFieldValue(FusionPro.Composition.inputRec ordNumber+9,"Codes");
var fileName = "ITEMNAME_" + FusionPro.Composition.currentOutputFileNumber + "_codes_" + Field("Codes") + "_thru_" + codeEnd + ".pdf";
FusionPro.Composition.outputFileName = fileName;

mclisa81
December 13th, 2013, 09:45 AM
Hi,

Thanks for the quick reply!

It's almost there. The only thing is that the last .pdf in the composition may not have 10 records, so it leaves the endcode blank on filename as below...

ITEMNAME_3_codes_w6MZ_thru_.pdf

Any idea for fixing that?

I'm going to play around with the rule you sent me and see if I can come up with anything.

Thanks for the help
Lisa

step
December 13th, 2013, 10:49 AM
Oh, I see. Probably the easiest thing to do is to modify the 'codeEnd' variable to look like this:

var codeEnd = input.GetFieldValue(FusionPro.Composition.inputRec ordNumber+9,"Codes") || input.GetFieldValue(input.recordCount,"Codes");

mclisa81
December 13th, 2013, 10:55 AM
EXCELLENT! Thanks for all your help and Happy Holidays!