-
1. Re: Why is my startup script getting a timeout error in FrameMaker?
frameexpert Nov 22, 2014 6:23 PM (in response to DianaFrameGirl)Hi Diana, Does the batch file do anything else besides start up FrameMaker? Can you take a screenshot of the error message and post it? Thanks. -Rick
-
2. Re: Why is my startup script getting a timeout error in FrameMaker?
DianaFrameGirl Nov 22, 2014 7:04 PM (in response to frameexpert)Hi Rick,
Yes, the batch file does a little basic dos-mode logging but that is the only other thing it does besides start FrameMaker. I'll attach two screen shots. The message tends to vary slightly, pointing to different lines of the ExtendScript, but basically saying it timed out, each time.
Thanks,
Diana
-
3. Re: Why is my startup script getting a timeout error in FrameMaker?
frameexpert Nov 23, 2014 8:32 PM (in response to DianaFrameGirl)Thanks for the screenshots. I am unfamiliar with these errors, so I may need to see your code. Let me know if you want to meet. Thanks. -Rick
-
4. Re: Why is my startup script getting a timeout error in FrameMaker?
Russ Ward Nov 24, 2014 4:39 AM (in response to frameexpert)Hi Diana,
I too have never seen an ES timeout error, but I have never tried to run an ES script the way you are. It is an interesting methodology and it seems like it should work. My initial suspicion is that there is some kind of bug in FM, not in your code. I don't see how a simple Date constructor should cause such a big problem.
If the script reliably saves at least one book, consider this possible workaround... change your script to process a single book only and restart FM for each book. Your DOS script could write a small text file somewhere that contains a book path, then your ExtendScript could read that file to determine which book to process. A bit more overhead, but I would try it if you can't find a way to fix the original problem.
Russ
-
5. Re: Why is my startup script getting a timeout error in FrameMaker?
DianaFrameGirl Nov 24, 2014 10:21 AM (in response to frameexpert)Thanks, Rick. Here is the body of the Extendscript that is in the FM Startup directory. The batch file starts FM and then this script gets kicked off.
main();
function main() {
log("Starting the script.");
var controlFile = File("G:\\fmToPdf\\fmToPdf.control");
var controlContent = null;
if(controlFile.exists === true) {
// Open the file.
controlFile.open("r"); // r means read only.
// Read the file contents into a variable.
controlContent = controlFile.read();
// Close the file.
controlFile.close();
}
var bookRegEx = /^book="(.*)"/;
var targetRegEx = /^target="(.*)"/;
var pathRegEx = /([^\\]+)$/;
var lines = controlContent.split("\n");
for (i = 0; i < lines.length; i++) {
var line = lines[i];
if (bookRegEx.test(line) === true) {
var result = line.match(bookRegEx);
var inBook = result[1];
var pathComponents = pathRegEx.exec(inBook);
var fileName = pathComponents[1].replace("book", "pdf");
for (i = i + 1; i < lines.length; i++) {
line = lines[i];
if (targetRegEx.test(line)===true) {
result = line.match(targetRegEx);
var outBook = result[1] + fileName;
log("Starting to generate: " + outBook);
fileId = openBook(inBook);
saveBook(fileId,outBook);
closeBook(fileId);
log("Finished with: " + outBook);
} else {
break;
}
}
}
}
// close FrameMaker
Constants.FF_CLOSE_MODIFIED = 1;
app.Close (Constants.FF_CLOSE_MODIFIED);
log("We're done.");
return;
}
function openBook(filename)
{
var openProp = GetOpenDefaultParams();
var retParm = new PropVals();
var BookOpen=Open(filename,openProp,retParm);
return BookOpen
}
// save as pdf
function saveBook(file, pdfName)
{
var saveProp = GetSaveDefaultParams();
var i = GetPropIndex(saveProp, Constants.FS_FileType);
saveProp[i].propVal.ival = Constants.FV_SaveFmtPdf;
//i = GetPropIndex (saveProp, Constants.FS_DontNotifyAPIClients)
//saveProp[i].propVal.ival = true;
var retParmspdf = new PropVals();
// pdf settings
file.PDFBookmark = true;
file.PDFBookmarksOpenLevel = Constants.FV_PDFBookmarksOpenDefaultLevel;
file.PDFConvertCMYKtoRGB = true;
file.PDFDistillerAbsent = 0;
file.PDFJobOption = "High Quality Print";
file.PDFSeparateFiles = false;
file.DocIsViewOnly = 1;
file.Save(pdfName, saveProp, retParmspdf);
return
}
// close file
function closeBook(filename)
{
filename.Close (Constants.FF_CLOSE_MODIFIED);
}
function log(message, reset)
{
var logfile = File("G:\\fmToPdf\\fmToPdf.log");
var openMode = (reset === undefined) ? "a" : "w";
logfile.open(openMode);
logfile.writeln(getTimeStamp() + " " + message);
logfile.close();
}
function getTimeStamp(){
var d = new Date();
var timestamp = d.getFullYear() + "." +
zeroFill ((d.getMonth() + 1), 2) + "." +
zeroFill (d.getDate(), 2) + " " +
zeroFill (d.getHours(), 2) + ":" +
zeroFill (d.getMinutes(), 2) + ":" +
zeroFill (d.getSeconds(), 2);
return timestamp;
}
function zeroFill( number, width )
{
width -= number.toString().length;
if ( width > 0 )
{
return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;
}
return number + ""; // always return a string
}




