See if the code below makes sense to you.
#target framemaker
var pgfName; // Global variable.
setupNotifications ();
function setupNotifications () {
// Set notifications for before and after functions. Notification(Constants.FA_Note_PostFunction, true); Notification(Constants.FA_Note_PreFunction, true);
}
function Notify (note, object, sparam, iparam) {
// Handle the pre- and post-function events. switch (note) { case Constants.FA_Note_PreFunction : if (object.constructor.name === "Doc") { pgfFmtName = getPgfFmtName(object); } break; case Constants.FA_Note_PostFunction : if (object.constructor.name === "Doc") { alert (pgfFmtName); // Paragraph format name before function. alert (getPgfFmtName(object)); // Paragraph format name after function. } break; }
}
function getPgfFmtName (doc) {
var pgf = doc.TextSelection.beg.obj; if (pgf.ObjectValid() === 1) { return pgf.Name; } else { return ""; }
}