Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

When is a script closed (time of unregistering)?

$
0
0

Dear friends and experts!
To avoid one (or more) of the special effects reported in this forum Klaus Göbel proposes to unregister the script when it is closed. But: when is the script closed?

I did not get a formal education in interactive programming, hence I have no real clue about the process: what is calling what. My programming experience is in procedural languages starting with Fortran in the 1960ies.

Please point me to a document describing all this - the Scripting Guide does not tell. And of course JavaScript books don't either.
The only sample script using Notify is FM_Suppress_Alerts.jsx and this is absolutely simplistic.
My understanding is this:

  • Starting the script registers it - 'purchases' a watch dog (IMHO not the same as registering an FDK client).
  • After starting the script it establishes the menu and configures the watchdog called Notification.
  • Within FM there is a nother watchdog barking at (the cat) Command when a menu item is selected.
  • Command calls the appropriate routine and then sleeps again (return tells the watch dog: have done!)
  • Notify is waked up on special events and calls appropriate routines (return tells the watch dog: have done!)
  • After a user has performed a menu selection and the the requested functions have been performed: where are we in the script? At the end of Command? At the end of main (that's really unreasonable).

The main structure of my script is this:

// --- Windows ID must be set outside the dialogue function to be available for Notify functions
var wPalC  = new Window("palette","FM-calc : Handle #calc Markers",    undefined);
//... also wPalS and wPalDS  main ();

function main () {
  SetUpGlobals ();                                // all global variables and constants  SetupFMcalc ();                                 // get inital data -- debug to be set explicitly  SetupNotifications ();                          // notification trigger 'Change document' etc.  // --- During development switch between the two following statements:  SetUpMenus(); // uncomment for real work  //DebugMenu (); // comment for real work - debugging does not work with menus
}
#include funGlobals.jsx
//... more includes
function SetUpMenus () {   //...
}
function Command (cmd) {   //...
}
function SetupNotifications () {   //...
}
function RemoveMyNotification() {   //...
}
function Notify (note, object, sparam, iparam) {   //...
}
//--- now follow the functions directly called from Command
function OpenHelpFile ()
function DoFMcalcInSelection()
function DoFMcalcInDoc () 
function DoFMcalcInBook () 
function HandleCalcMarkers()
function HandleSeriesMarkers()
function HandleDocSettings()
//...And all the others which I want to have in this module

In the past I had the call of RemoveMyNotification in the call-back functions for the Cancel/Exit buttons in the panels. But now I guess that the best place would be at the end of the Command function: After anything has been done.
But: SetUpNotifications is within the main function and will not be executed anymore after the script has been started the first time.

I need a better insight, sigh!


Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>