• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

FM-14: strange behaviour of SetUpMenu function

Community Expert ,
May 13, 2017 May 13, 2017

Copy link to clipboard

Copied

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?

TOPICS
Scripting

Views

261

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 22, 2017 Jun 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

Votes

Translate

Translate
Community Expert ,
Jun 20, 2017 Jun 20, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 22, 2017 Jun 22, 2017

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines