Skip to main content
K.Daube
Community Expert
Community Expert
February 9, 2015
Answered

How to cope with "undefined is not an object" ?

  • February 9, 2015
  • 2 replies
  • 1260 views

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.propVal.ival = Constants.FV_AllowAllRefFilesUnFindable;    i = GetPropIndex(params, Constants.FS_FileIsOldVersion);    params.propVal.ival = Constants.FV_DoOK;    i = GetPropIndex(params, Constants.FS_FontNotFoundInDoc);    params.propVal.ival = Constants.FV_DoOK;    i = GetPropIndex(params, Constants.FS_LockCantBeReset);    params.propVal.ival = Constants.FV_DoOK;    i = GetPropIndex(params, Constants.FS_FileIsInUse);    params.propVal.ival = Constants.FV_OpenViewOnly;    i = GetPropIndex(params,Constants.FS_AlertUserAboutFailure);    params.propVal.ival=Constants.FV_DoCancel;  /*   i = GetPropIndex(params,Constants.FS_MakeVisible );    params.propVal.ival=false;  */   return (params);  }

(inserting JS code really has its quirks in this editor).

This topic has been closed for replies.
Correct answer Klaus Göbel

Hi Klaus,

There's missing something like this in you function GetTplParams() :

params = GetOpenDefaultParams();

2 replies

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
February 10, 2015

Thanks Klaus - now it works!

To Rick.

The presented piece of code is part of a 're-furbishing' the FameMaker to EndNote 'connection.

In a first step I collect temporary citations (such as [Daube, 1969, #123] ) from text, footnotes and tables into an array. This part already works fine (I had to postpone further development for a year now...).

Then I write this data to a new document (which is created from the template - this is where the mentioned piece comes into play.

This file then is saved as rtf to be worked off by the bibliographic application EndNote (or Citavi in another case) to resolve the temporary citation into formatted citations and the bibliography.

After that the modified rtf is read in FM and the temp. citations in the FM-document/book are replaced by the formatted citations.

The user then copies the bibliography (as text only) into his appropriate chapter/section and formats it to his liking.

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
February 9, 2015

To get the code somewhat more useful, see https://dl.dropboxusercontent.com/u/55332862/t-very-simple.jsx

Klaus Göbel
Klaus GöbelCorrect answer
Legend
February 9, 2015

Hi Klaus,

There's missing something like this in you function GetTplParams() :

params = GetOpenDefaultParams();