If the incoming file have Width 100 and Width 200 I want to return/log 300 in the calculation function.
Code: Select all
function jobArrived( s : Switch, job : Job )
{
var xmlSize, pdfSize;
//xmlSize = 100, pdfSize = 200
if(job.isType("xml")) {
xmlSize = getXmlSize();
}
if(job.isType("pdf")) {
pdfSize = getPdfSize();
}
function getXmlSize() {
var theXML = new Document(job.getPath());
var xmlWidth = theXML.evalToString("//PrintWidthCover");
return xmlWidth;
}
function getPdfSize() {
var pdfWidth = job.getVariableAsNumber("[Stats.PageWidth]");
return pdfWidth;
}
calculateSize(xmlSize, pdfSize);
function calculateSize(xml, pdf) {
s.log(2, "Result: " + xml + pdf);
}
}
How can I call the function "calculateSize" ONE time and get one result, 300, the result of the xml size on 100 + pdf size on 200?
I get the result in the log if I use the code above:
Job *.XML - Result: 100undefined
Job *.PDF - Result: undefined200