Skip to main content
K.Daube
Community Expert
Community Expert
May 13, 2017
Answered

FM-14: strange behaviour of SetUpMenu function

  • May 13, 2017
  • 2 replies
  • 361 views

Friends and gurus: I encounter a very strange situation!

The following script works correctly. The functions are called by a button.

#target framemaker

var gasETBViewSettings = [];                      // save the user settings
var gsETBMsgNoDoc   = { en: "No document active!",
                        de: "Kein dokument aktiv!"
                      };
// alert ("ETBToggleViewsA really entered");
SetUpMenu();

function SetUpMenu() { // ==== Define the menu - even if not used =================================
var sLabelEditing, sLabelPrinting, menuLocation, cmdDoc1, cmdDoc2;
  menuLocation = app.GetNamedMenu("ETBdummy");    // Required, even if not used
  cmdDoc1 = DefineCommand (1, "EditingDisplay",  "Document Editing Display [ETB]",  "\!qqe");
  cmdDoc2 = DefineCommand (2, "PrintingDisplay", "Document Printing Display [ETB]", "\!qqp");
  UpdateMenus();
} // --- end SetUpMenu

function Command(cmd) { // ==== Respond to menu/TB command ==================================
alert ("ETBToggleViewsA command " + cmd + " entered");
    switch(cmd)  {
        case 1:
      SetEditingDisplay();
      break;
        case 2:
      SetPrintingDisplay();
      break;
    }
} // --- end Command

function SetEditingDisplay () {

  alert ("SetEditingDisplay entered"); // of course there is more in here

}

function SetPrintingDisplay () {

  alert ("SetPrintingDisplay entered"); // of course there is more in here

}

But if I insert the following after line 11, then the script does not work anymore (it is loaded, but the Command function does not issue the alert etc.).

  sLabelEditing  = { en: "Document Editing Display [ETB]",
                     de: "Ansicht für Dokument Bearbeitung [ETB]" };
  sLabelPrinting = { en: "Document Printing Display [ETB]",
                     de: "Ansicht für Dokument Drucken [ETB]" };

It doesn't work either if I place the following after line 06:

var gsLabelEditing  = { en: "Document Editing Display [ETB]",
                     de: "Ansicht für Dokument Bearbeitung [ETB]" };
var gsLabelPrinting = { en: "Document Printing Display [ETB]",
                     de: "Ansicht für Dokument Drucken [ETB]" };

I have similar constructs in various scripts with no problems so far.

What is going on here?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer K.Daube

Guess What?

After carefully checking differences between a working stub and the full script I discovered the difference:

The script must be coded in UTF-8 (it was Windows code page 1252).

Wouldn't be a message about this possible?

Klaus

2 replies

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
June 20, 2017

Since I had a problem with Windows update (see https://forums.adobe.com/thread/2346713) even this simple script does not work anymore - neither in FM-14.0.0.361, nor in update 1 nor in update 2.

The menu set up function is run on start of FM, but the command function is not invoked - neither by shorcut nor by a button which specifies the command.

This is a very stripped down version of the real script, which can be found on my website. It works if invoked in test mode - without menu set up.

The absolute wierd thing is that all this has worked before the roblem with the Windows update (both build 361 and 406 - 415 was'n there at that time).

All the other scripts I now have in the Enhanced Tool Bar work as intended. They are in the Startup folder and are invoked by button (Insert Symbol also by menu item):

ETBinsertSymbol_en.jsx     has Notify function to bypass initial start, sets up menu items, used by button

ETBSaveAsOld.jsx           with similar set up

ETBtest.jsx            just a stub with similar setup

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthorCorrect answer
Community Expert
June 22, 2017

Guess What?

After carefully checking differences between a working stub and the full script I discovered the difference:

The script must be coded in UTF-8 (it was Windows code page 1252).

Wouldn't be a message about this possible?

Klaus