[JS CS4] Getting unexpected filenames - *TempScratchDocument*
Skempy Jun 9, 2010 3:39 AMHi,
I have a Startup Script which launches event handlers to write to a log file when an InDesign document is opened and closed.
The functions write the filename, username and time of the event to the log file but I am getting unexpected filenames written to the log and wondered if anyone could explain where these are coming from.
An example from the log file is:
Started: Untitled-4 lhusband Wed Jun 09 2010 10:55:34
Finished: -/*TempScratchDocument*/- lhusband Wed Jun 09 2010 10:55:34
It is the -/*TempScratchDocument*/- bit I don't understand.
My thoughts are that doing a copy/paste or saving a snippet or putting something in a library could be creating a "new" temporary document somewhere in InDesign memory, but I cannot replicate this on my own PC.
This script is running on 30 PCs and I only get this for 2 or 3 users.
The event listeners are:
var myEventListener1 = app.addEventListener("afterOpen", openJob, false);
var myEventListener2 = app.addEventListener("afterSaveAs",openJob, false);
var myEventListener3 = app.addEventListener("afterNew",openJob, false);
var myEventListener4 = app.addEventListener("beforeClose", closeJob, false);
var myEventListener5 = app.addEventListener("beforeSaveAs",closeJob, false);
The two function called are:
function openJob(myEvent) {
var myDate = new Date;
var myTime = myDate.toString();
var myEventTime = myTime.slice(0,-9);
var user=getUser(); // function to get username
try { var myPath = myEvent.parent.fullName } catch(e) { var myPath = myEvent.parent.name } // to handle unsaved documents
// Write to Jobs.Log
myFile = File("//10.19.55.220/Logs/jobs.log");
myFile2.open("a");
myFile.write('\n' + "Started:" + '\t' + decodeURI(myPath) + '\t' + user + '\t' + myEventTime);
myFile.close();
} // end of function
function closeJob(myEvent) {
var myDate = new Date;
var myTime = myDate.toString();
var myEventTime = myTime.slice(0,-9);
var user=getUser(); // function to get username
try { var myPath = myEvent.parent.fullName } catch(e) { var myPath = myEvent.parent.name } // to handle unsaved documents
// Write to Jobs.Log
myFile = File("//10.19.55.220/Logs/jobs.log");
myFile2.open("a");
myFile.write('\n' + "Finished:" + '\t' + decodeURI(myPath) + '\t' + user + '\t' + myEventTime);
myFile.close();
} // end of function
If anyone can shed any light on this I would be most grateful.
Thanks
Simon Kemp.
