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

How to unregister script programmatically ?

Community Expert ,
Jun 28, 2016 Jun 28, 2016

Copy link to clipboard

Copied

Friends, Romans, Countrymen!

Lend me your ears! [Shakespeare: Julius Cesar]

During testing a script wich has a notification It is necessary to uninstall it every time before it is run again (after some modification). Doing this via the script catalog is at least time consuming.

If I do not do this, then old code may be executed and the Data Browser shows items which are no more in the script...I even have to start FM and the ESTK again and again during the tests. In the Notify function it is also not possible,

  • to set a breakpoint
  • to use $.writeln.

The only feedback functions are alert, Alert and Console. It is, however, possible to set a breakpoint in a called function. Since some of them are called from the Notify function I need to place several...

I have tried to place the unregistering code at the Cancel button of the dialogue the functions of which I'm testing:

wPalDS.g1.Cancel.onClick = function () {
  wPalDS.close();
  Notification (Constants.FA_Note_PostActiveDocChange, false);   // unregister script

}

But this does not work - the script is still registered after cancelling.

For debugging the Scripting Guide refers to the JavaScript Tools Guide - which does not touch such delicate situations at all.

Do You have a trick to see both the global items and the local (to a function) variables and objects in the Data Browser? Currently I use such constructs as var a1 ...:

function RefreshGlobalsDS () {
$.bp(true);
  GetRefPageItems ("Ref-Locations");              // gasLocations
  GetRefPageItems ("Ref-Formats");                // gasFormats
  GetRefPageItems ("Ref-Schemes");                // gaoTxtSchemes
var a1 = gasLocations, a2 = gasFormats, a3 =  gaoTxtSchemes;
  FillItemList (wPalDS.p0.tabL.g1.p1.listLocations,  gasLocations);  // undefined is not an object ????
  FillItemList (wPalDS.p0.tabF.g1.p1.listFormats,    gasFormats);
  FillSchemeList (wPalDS.p0.tabT.g1.p1.listSchemes,  gaoTxtSchemes);
}

Any tips and tricks at hand?

TOPICS
Scripting

Views

468

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

Enthusiast , Jun 28, 2016 Jun 28, 2016

Hi Klaus,

did you try to swap lines2 and 3 ?

First remove thenotification ?

I do it like this:

wPalDS.onClose = RemoveMyNotification;

function RemoveMyNotification()

{

Notification(Constants.FA_Note_PostActiveDocChange, false);

}

Just give it a try.

Votes

Translate

Translate
Enthusiast ,
Jun 28, 2016 Jun 28, 2016

Copy link to clipboard

Copied

Hi Klaus,

did you try to swap lines2 and 3 ?

First remove thenotification ?

I do it like this:

wPalDS.onClose = RemoveMyNotification;

function RemoveMyNotification()

{

Notification(Constants.FA_Note_PostActiveDocChange, false);

}

Just give it a try.

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 29, 2016 Jun 29, 2016

Copy link to clipboard

Copied

LATEST

Thank You, Klaus!

Have placed wPalDS.onClose = RemoveMyNotification; in the dialogue towards the end.

This works as intended!

However, I have to think more about this: In the final script it will be to early to unregister at closing the dialgoue. The user may choose to use another menu-item thus opening another dialogue or issuing another function - and the script is no more registered and hence will not react on change of document.

For the final version it may be best to unregister at the close of the FM session. But for now it's a releaf.

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