Script OK in FM12/13, not in FM10/11
Dear friends and experts,
I can run without problems any of my installed FMs (6 ... 13). The last installed was FM 13 aka 2015.
In all FMs since version 10 I can run scripts - but have no clue which ESTK they are using.
On drive C I find ExtendScript Toolkit CS4, ...CS5 and ...CS6. They have been installed with the various FMs
When testing my script (developing in FM12) in FM 10 or 11 I get an error on line 11: undefined is not an object
Which cure might be necessary to run the script also in older FMs?
function CreateBibDoc () {
// ----------------------------------------------- create new doc from template and fill it
// returns created doc in function
giLvlTrace += 1; ZTrace ("CreateBibDoc");
var j, uniqueCitations= [], nUnique, nItems, insText, newDoc, pgf, textloc, j;
var writeFile = GetDocPath () + gsCollectFile;
// create array of unique citations and place them in the doc
uniqueCitations = SortUnique (gasFndCitations);
nUnique= uniqueCitations.length;
// createa new file
newDoc = OpenTemplate (); // FM-10/11 error FM-12/13 OK
pgf = newDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf; // get first pgf in flow
for (j = 0; j < nUnique; j += 1) {
textLoc = new TextLoc (pgf, 0);
insText = uniqueCitations;
newDoc.AddText (textLoc, "[["+insText+"]]"+ "\x08" + "{"+insText+"}"); // \t inserts a NL...
if (j < nUnique -1){
pgf = newDoc.NewSeriesPgf(pgf); // add a paragraph
}
}
giLvlTrace -= 1;
return newDoc;
} // --- end CreateBibDoc
function OpenTemplate () {
// ----------------------------------------------- Open template file
// return the Open file in the function
giLvlTrace += 1; ZTrace ("OpenTemplate");
var tplDir, tplFile, openParams, openReturnParams, oFile;
tplDir = GetScriptPath ();
tplFile = tplDir + "\\" + gsTemplate;
// oFile = SimpleOpen (tplFile, true); // Opens the dir of the active document
openParams = GetTplParams ();
openReturnParams = new PropVals();
oFile = Open (tplFile, openParams, openReturnParams);
giLvlTrace -= 1;
return oFile;
} // --- end OpenTemplate



