Skip navigation
Currently Being Moderated

event-driven extendscript

Dec 27, 2013 6:01 AM

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

 
Replies
  • Currently Being Moderated
    Dec 27, 2013 6:08 AM   in reply to rombanks

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 27, 2013 7:38 AM   in reply to rombanks

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 27, 2013 8:33 AM   in reply to rombanks

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 30, 2013 4:45 AM   in reply to rombanks

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points