I'm tiptoeing towards a solution, but stepped on a thumbtack:
The following snippet creates an error in the function GetTplParams
var template = "DDD-BibFM-tpl.fm"; // located in script-dir var outFile = "DDD-BibFM.fm"; // located in the source dir oDoc = OpenTemplate (); alert ("Is template open now?"); function OpenTemplate () { var tplDir, tplFile, openParams, openReturnParams, oFile; tplFile = "E:\\_DDDprojects\\FM+EN-escript\\escript\\DDD-BibFM-tpl.fm" // SimpleOpen does not take the tplFile, but opens the dir of the active document // oFile = SimpleOpen (tplFile, true); openParams = GetTplParams (); openReturnParams = new PropVals(); oFile = Open (tplFile, openParams, openReturnParams); return oFile; } function GetTplParams() { // =>>> "undefined is not an object" on line 22 var params, i; // Change the params i = GetPropIndex(params, Constants.FS_RefFileNotFound); params[i].propVal.ival = Constants.FV_AllowAllRefFilesUnFindable; i = GetPropIndex(params, Constants.FS_FileIsOldVersion); params[i].propVal.ival = Constants.FV_DoOK; i = GetPropIndex(params, Constants.FS_FontNotFoundInDoc); params[i].propVal.ival = Constants.FV_DoOK; i = GetPropIndex(params, Constants.FS_LockCantBeReset); params[i].propVal.ival = Constants.FV_DoOK; i = GetPropIndex(params, Constants.FS_FileIsInUse); params[i].propVal.ival = Constants.FV_OpenViewOnly; i = GetPropIndex(params,Constants.FS_AlertUserAboutFailure); params[i].propVal.ival=Constants.FV_DoCancel; /* i = GetPropIndex(params,Constants.FS_MakeVisible ); params[i].propVal.ival=false; */ return (params); }
(inserting JS code really has its quirks in this editor).