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

Special effects (mostly unwanted)

Community Expert ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

Dear friends,
We all know about special effects in the movies, but I can tell you: also ExtendScript can entertain us with such. It appears to be a conjurer of the good old style. It all happens on the stage of FM version 13.0.5.547.
Information for the uninitiated:

  • The script creates a menu with some entries
  • Two entries immediately open a panel to work with special markers
  • Other entries open the pdf documentation, open a panel for document settings or run functions through the document.
  • Debugging is not possible when functions are called via the menu. Hence for debugging I disable the set-up of the menu and present a selection list with the jumps to the functions.
  • I unregister the script each time before I start it again (either in ESTK or via script catalogue).

The Ghost

When opening one of the panels via menu it happens that in the top left corner a small selection list appears with contents from a previous call:

magic-ghost.png
I can create this illusion at will with the following sequence of magic tricks. No, it's not an illusion: Putting the cursor into the selection list the display can be changed with the arrow keys, so it's some sort of real...

  1. Leave all script activity (panels)
  2. Unregister the script
  3. Open a panel by the still 'active' menu in FM
  4. Voilà! The ghost appears in top left corner

The slave

From time to time (magic does not happen by schedule) the following effect can be seen:

  1. Starting the script before an FM document is open
  2. Invoking a script action via menu
  3. I do not see the panel - it is in the background
  4. Not certain about an error I bring the console window to the foreground
  5. Not seeing anything suspicious I dismiss the console window to get a fresh version for an error.
  6. At the same time the panel disappears, following 'his master' immediately to the nirvana.

Unfortunately I can not reproduce this at will... Hence I do not know whether an open ESTK (with nothing in there) has any influence.

The twins

I discovered this after a small update of my script and hence guessed the reason for it there - but my update was in a mathematical function, not in the area of the user interface:

magic-twins.png

  1. Open FM and then create a new document
  2. Invoke the script via catalogue and select a panel function from the menu
  3. The contents of the panel is duplicated
  4. Each 'content' is active independently of the other - see the different tabs in the screen shot.
  5. But I am not certain which one really performs the function in the document.
  6. Hence I dismiss these Siamese twins.
  7. Then I opened a document which behaved 'last time'
  8. Unregister script, start script again, open panel via menu
  9. Same effect
  10. Now I left FM and started afresh
  11. The magic did not appear any more (sorry folks!).

Big entertainment, isn't it? But frustrating when trying to get a good script...

What can we learn from these tricks?

TOPICS
Scripting

Views

416

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
Enthusiast ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

Hi Klaus,

there's one point that astonishes me:

I unregister the script each time before I start it again (either in ESTK or via script catalogue).

Don't you unregister the notification when the script is closed? (by User or script)

Notification(Constants.FA_Note_PostMouseCommand,false);

If you don't do that, the event could be driggered a second time, when the user starts this script again. (I don't know the possible results).

The other reason for some strange behaviour could be using a variable with the same name in different scripts. So they can interfere.

Example for your "TWINS":

w = new Window("palette","TEST",undefined);

panel = w.add("tabbedpanel",undefined);

tab1 = panel.add("tab",undefined,"Tab1")

When execute this script a second time, under some circumstances it can lead to your "twin-effect".

Just check your scripts with that view.

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 ,
Dec 01, 2016 Dec 01, 2016

Copy link to clipboard

Copied

Thank you, Klaus for your thoughts about these effects.

Don't you unregister the notification when the script is closed? (by User or script)

When is a script closed?

I had this unregistering coupled with the Cancel/Exit buttons in the panels - but was not certain whether this hinders a second open of them via menu.

After start of the script (and establishing the menu) It should be possible to

  • invoke panels independently of each other (menu) and have them open in parallel
  • invoke the same panel again after it has been closed
  • keep the panel(s) open even after closing the last document
  • update the panel(s) via Notification (change of document etc.)

Hence i decided to postpone this automatic unregistering until later.

But your interjection lets me try it again now.

The other reason for some strange behaviour could be using a variable  with the same name in different scripts. So they can interfere.

I will check again whether all local variables are really locally defined. Especailly in some longer functions (and the dialogue definitions are long (PaletteDocSettings: 350 lines, PaletteCalcMarkers: 200 lines) there could be some left unddefined (and hence treated global).

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 ,
Dec 12, 2016 Dec 12, 2016

Copy link to clipboard

Copied

LATEST

Dear friends,

For at least one of the mysteries I have broken the spell: The slave

For debugging purpose I had Console statements in the Notify function. When I later opened a panel via menu or keyboard short cut the console window came to the foreground and above it the panel appeared. Since not interested of the messages in the log at that time I dismissed (closed) the log window. At the same time the panel disappeared. And in addition the script was not registered any more...

Having replaced the Console statement by an alert the mystery disappeared.

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