9 Replies Latest reply on Nov 22, 2016 1:51 AM by K.Daube

    Can I do this with FrameMaker ExtendScripting?

    Egan Solo Level 1

      Using FM 12.0

      I'm a coder so coding is not the issue here. It's just my lack of familiarity with FM ExtendScript and the art of the possible.

       

      I want to create a script that

       

      1. Inserts a marker of a custom type called Editorial Changes. We can safely assume that this marker type (Editorial Changes) exists already.
      2. Displays an advanced marker window: Please see the mock-up window below. Studying sample scripts such as SnpCreateCheckBoxRadioButtons.jsx, I know I can create something like that window, so that's not an issue.
      3. Once the user has finished filling the fields, I want to capture the data and store it inside the marker field, say as an XML snippet.
      4. Later on, when a user selects a created marker of type "Editorial Changes," I want my script to intercept that event, grab the XML content from the marker and display my custom window with all these fields.

       

      Does the sequence outlined through steps 1-4 doable via an ExtendScript? If you've done something like that and have a script lying around, would you mind sharing?

       

      Thanks!

       

        • 1. Re: Can I do this with FrameMaker ExtendScripting?
          frameexpert Level 4

          There are a bunch of events triggered by FrameMaker, but I don't know if there is one that is specifically triggered when a marker is selected. There are a couple of general purpose events like:

           

          Constants.FA_Note_BackToUser

          Constants.FA_Note_PreFunction

          Constants.FA_Note_PostFunction

           

          Here is a general shell for setting up notifications. In this example, the script is looking for a paste event to happen, which is 803. I figured out the 803 by setting up the event and monitoring the iparam value as I copied/pasted text and objects.

           

          function Notify (note, object, sparam, iparam) {
              
              var doc;
              
              // Handle the event triggered after a function is performed.
              switch (note) {
               
              case Constants.FA_Note_PostFunction:
                  // Look for paste function.
                  if (iparam === 803) {
                      doc = object;
                      if (doc.FirstSelectedGraphicInDoc.ObjectValid()) {
                          // If the document has a selection, turn off its runaround property.
                          RN.turnOffRunaround (doc.FirstSelectedGraphicInDoc);
                      }
                  }
                  break;
              }
          }
          
          // Set the notification for after a function is executed.
          Notification (Constants.FA_Note_PostFunction, true);
          
          • 2. Re: Can I do this with FrameMaker ExtendScripting?
            frameexpert Level 4

            I suggest that you download and install the latest FDK (Frame Developers Kit). The documentation has some examples of events/notifications and how they work. The examples will be in C, but it is fairly easy to translate them to ExtendScript.

            • 3. Re: Can I do this with FrameMaker ExtendScripting?
              frameexpert Level 4

              Note also that FrameMaker markers have an internal limit of 255 characters. I am not sure if this has changed in later versions, but you should test this before you get too far into development.

              • 4. Re: Can I do this with FrameMaker ExtendScripting?
                Egan Solo Level 1

                Thank you so much for your guidance, FrameExpert, especially in regards to the size of the marker. That's a great pointer. I might then create an auxiliary file to store the content in it and reload it into the window based on a marker id. To your point though, figuring it out if there is a notification for markers will be the greatest hiccup. I'll download the latest sdk. I'll report back as soon as I make some progress into this.

                • 5. Re: Can I do this with FrameMaker ExtendScripting?
                  frameexpert Level 4

                  Another suggestion would be to use a reference page to store the content. If you have a named reference page with a text frame with a named flow and autoconnect turned on, new reference pages will automatically be created as content overflows the reference page. That would make all of your data self-contained in the file so you won't need an auxiliary file.

                  • 6. Re: Can I do this with FrameMaker ExtendScripting?
                    Egan Solo Level 1

                    Thanks for the latest suggestion.

                    I tried the bit of code you shared with me to try and capture the event for the creation of a marker, but I must be missing something very basic. As soon as I run the code, it terminates. In other words, it sets the notification, per the line

                     

                    Notification (Constants.FA_Note_PostFunction, true); 

                     

                    Then it exits.

                     

                    I get it that this line turns the notification to true, what I am not getting is how is the method you wrote

                     

                    function Notify (note, object, sparam, iparam)

                     

                    Is able to handle this event, unless, of course, the scripting engine looks for a method called Notify.

                     

                    As you can see, I've got a few basic chores I've got to go through to get situated. I plan on reading up on event handling in the SDK docs and hopefully I'll get the initial stuff going.

                     

                    Not sure how to setup the reference pages to store content, but I'll get to it once I've got the basic stuff going

                     

                     

                     

                    • 7. Re: Can I do this with FrameMaker ExtendScripting?
                      frameexpert Level 4

                      Notify is a built-in function that "waits" for the events you specify with the Notification command to happen.

                      • 8. Re: Can I do this with FrameMaker ExtendScripting?
                        Klaus Göbel Level 3

                        frameexpert schrieb:

                         

                        Note also that FrameMaker markers have an internal limit of 255 characters. I am not sure if this has changed in later versions, but you should test this before you get too far into development.

                         

                        Since FrameMaker 12 it is 1023 characters.

                         

                        But the script has to check the FrameMaker Version and the amount of characters.

                         

                        Using a reference page is a better way (Rick, thanks for that suggestion).

                        Warning: When using a reference page you must ensure, that the name of the reference page is unique, not only in that document, but in all of your documents.

                        Because if you import reference pages from other documents, your reference page might  be overridden.

                        • 9. Re: Can I do this with FrameMaker ExtendScripting?
                          K.Daube Level 1

                          IMHO the solution with a areference page is very flexible.

                          In my ongoing project I use this technique. If the ref-page does not exist, it is read from a template thus defining defaults for the process. I have both junks of paragraphs and ini-like definitions:

                          ; [Ref-Setting]

                          ; Character format for superscripting            
                          FmtSup = super
                          ; Decimal separator (period)
                          FmtDecimal =.
                          ; Thousands separator (thin space \u2009)
                          FmtThousand =  
                          ; Default output formats for real
                          FmtReal = {E4}
                          ; Default output formats highlight
                          FmtHigh = highlight;

                          ; [Ref-Variables]
                          ; Although variables are collected in the document, they are also listed here.
                          #DOCname
                          #T1
                          #T2

                          Lines starting here with ; are comments and use ¶ format Re-comment; the lines with the = use ¶ format Ref-Setting and those in 'section' [Ref-Variables]' use ¶ format Ref-Variables.