3 Replies Latest reply on Mar 2, 2012 5:19 AM by frameexpert


    Jason L-S Level 1

      I want to change the paragraph style to "CellBodyRight" using a simple Fcode script.


      FcodeList = new Array(FCodes.KBD_PGFQUICK, 'CellBodyRight', FCodes.KBD_RETURN);




      However, when FCodes.KBD_PGFQUICK is executed, FrameMaker waits for user input.


      Instead, I want the string "CellBodyRIght" to simulate the user typing that paragraph format name.





        • 1. Re: FCodes.KBD_PGFQUICK
          frameexpert Level 4

          Hi Jason,


          I would discourage the use of FCodes to do this type of thing. It is much better to use built-in ExtendScript functions. FCodes only work on the active document, but ExtendScript functions can be used on any valid document. For example, if doc is your document object, you can use this to apply CellBodyRight to the paragraph containing the insertion point.


          var doc = app.ActiveDoc;
          var pgf = doc.TextSelection.beg.obj;


          // Apply the paragraph format to the paragraph.


          function applyPgfFmt(pgf,name,doc) {
              // See if the paragraph format exists in the document.
              var pgfFmt = doc.GetNamedPgfFmt(name);
              if (pgfFmt.ObjectValid()) {
                  // If the format exists, apply its properties to the paragraph.
                  var props = pgfFmt.GetProps();
              else {
                  // If the format does not exist, apply the format name only.
                  pgf.Name = name;



          • 2. Re: FCodes.KBD_PGFQUICK
            Jason L-S Level 1

            Thanks Rick. That worked.


            So I assume FCodes are useful for quick solutions, right? In this case I wanted to quickly write a script to rotate the selected body cells, and then format the text as CellBodyRight. I thought doing it with FCodes would be easier and quicker than doing it programatically, since I'm not an expert scripter.


            Is it possible to do what I had originally asked? I wanted to use the following sequence: FCodes.KBD_PGFQUICK, 'CellBodyRight', FCodes.KBD_RETURN.


            But that did not work. Could I use a different FCodes sequence to accomplish it?



            • 3. Re: FCodes.KBD_PGFQUICK
              frameexpert Level 4

              Hi Jason,


              I am not sure; I don't use FCodes much at all. As far as quick solutions, your best bet is to start a library of reusable functions like the one above. Then when you have a quick task, you can grab the appropriate function and plug it into your script. That is what I did to answer your question. I barely looked at the code but I knew that it would do what you wanted.