Stuck with Notify / registered script
Dear friends,
A Notify function is invoked even before I have explicitly started the script. Well this seems to be purpose of registering a script, but...
The Notify function is executed before the script could initalise and hence I get the message at start of FM (line number according to the code below):
Script Error :
Error Message : wPalC is undefined
Script, Line# : E:\_DDDprojects\FM-calc\FM-calc\FM-calc.jsx, 13
(actually this refers to the line 14, because only there wPalC appears.
The Notify routine handles two different dialogues the core of which are set up in functions. Only the window definition is global:
var wPalC = new Window('palette',"FM-calc : Handle #Calc Markers",undefined);
var wPalDS = new Window('palette',"FM-calc : Manage Document Settings",undefined);
//...
function SetupNotifications () { // Watch for the following notifications =========================
Notification (Constants.FA_Note_PostActiveDocChange, true);
} // --- end SetupNotificationsfunction Notify (note, object, sparam, iparam) { // Handle triggered evens =======================
//$.bp(true); // does not work at all
//alert ("Notify- object:\n" + object); // this works
switch (note) {
case Constants.FA_Note_PostActiveDocChange: // active document has changed
goCurrentDoc = object;
if (wPalC === undefined) {return;} // registered script is entered before really started
if (wPalC.active) {
if (!object.ObjectValid()) { // after all documents have been closed
HideButtonsC ();
return;}
giNdexOfMarker = RefreshGlobalsC (); // later: needs to distinguish marker types !!!
if (giNdexOfMarker !== null) {
DisplayMarker (goCurrentDoc, goCurrentMarker);
wPalC.p0.sMarkerContent.text ="";
gsMarkerText = goCurrentMarker.MarkerText;
wPalC.p0.sMarkerContent.textselection = gsMarkerText;
ActivateButtonsC ();
} else {
HideButtonsC ();
}
CollectVariables (true); // fill the global array
FillUserVars (wPalC.p0.g1.pVar.listVariables); // fill the diaolgue list
}
if (wPalDS.active) {
CollectVariables (true); // fill the global array
FillUserVars (wPalDS.p0.tabV.g1.p1.listVariables); // fill the diaolgue list
}
break;
}
} // --- end Notify
So how to test for an undefined something? Do I need ==== ?-)
if (!wPalC.ObjectValid()) {return;}
Does not work either - same error message.

