First of all, thank you very much for a detailed introduction to event-driven scripts!
Now, I also know that you have a blog, which is great.
I do have a couple of questions.
1. It not clear to me how to add a "Registered" script to the FM script catalog. This option is not documented well. The FM help says that adding a script as registered is described "in the appendix", which does not exist.
2. In the sample script you presented on your blog, the following line is not defined anywhere else. How does this work?
Notification (Constants.FA_Note_PostGenerate, true);
3. function Notify (note, object, sparam, iparam) has 4 params, but only 2 of them are actually used. Why do you need to use "object" and "sparam" in this function?
4. When running the command code checking script, and then importing formats from another file, I get [Object InvalidObject] alert and not the command number. Please, advise!
5. Why would the Notify event be actually called twice?
Thank you a million! You are great!
My best wishes,
1. You have to "Run" the script to get it Registered. After you run it (or set it up as Autorun), it will show up in the Registered View of the Script Library palette.
2. This is a built-in FrameMaker ExtendScript function.
3. Different notifications may use different parameters. For example, FA_Note_PostSaveDoc will set sparam to the file name of the file that was just saved. The object is useful if you need to pass it to a function. For your script, object will be the Doc object of the target document. If you don't need a particular parameter in your script, just ignore it.
4. You should post your code so we can take a look. I tested mine and I get the command number.
5. I don't know; this may be a bug.
Thank you for your response!
1. For some reason, not all scripts become "Registered" when run. For example, your command code checking script becomes Registered when run. The Apply Master Pages script posted by Jang in the previous discussion works fine but is not added to "Registered" when run. I don't understand what the difference is. If added to Autorun, a script will appear under Autorun and not under Registered, as far as I can see.
2. OK, thank you!
3. Got it, thanks!
4. I tested yours and got "[Object InvalidObject]". BTW, I'm using FM 10, in case this matters.
5. I see. But how did you discover that the function is triggered twice?
Thank you again!
My best regards,
1. You have to make sure that your setupNotifications (); call is at the top of the script outside of any functions, etc. Otherwise, it won't be called when you run the script.
4. I am using FrameMaker 11. I just tried it with FrameMaker 10 and also get [Object InvalidObject]. Let me see if I can figure out a workaround.
5. Because 790 (or [Object InvalidObject]) is displayed twice.
Zero is probably correct for this event because the parameter isn't needed. When an event is specific like this one, you usually won't need to test the iparam or sparam parameters. For general events like FA_Note_PostFunction, any number of commands will trigger it, so you need to test iparam to see which one did.