Skip to main content
rombanks
Inspiring
December 27, 2013
Question

event-driven extendscript

  • December 27, 2013
  • 1 reply
  • 1753 views

Guys,

I wonder if there is there a way to make a script event-driven, so that it will be triggered, for example, after importing formats from another file? The FM help says that 'Registered' scripts are event-driven, but there is not even a word on how to define the event.

Thank you for your response in advance!

My best wishes,

Roman

This topic has been closed for replies.

1 reply

frameexpert
Community Expert
Community Expert
December 27, 2013

I wrote a blog post on this: http://frameautomation.com/?p=299

Please let me know if you have any questions or comments. Thanks. Rick

www.frameexpert.com
rombanks
rombanksAuthor
Inspiring
December 27, 2013

Hi Rick,

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,

Roman

frameexpert
Community Expert
Community Expert
December 27, 2013

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.

www.frameexpert.com