• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

FCodes.KBD_PGFQUICK

Community Beginner ,
Mar 01, 2012 Mar 01, 2012

Copy link to clipboard

Copied

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

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

Fcodes(FcodeList);

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.

Thanks!

Jason

TOPICS
Scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 01, 2012 Mar 01, 2012

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.
applyPgfFmt(pgf,'CellBodyRi

...

Votes

Translate

Translate
Community Expert ,
Mar 01, 2012 Mar 01, 2012

Copy link to clipboard

Copied

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.
applyPgfFmt(pgf,'CellBodyRight,doc);

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();
        pgf.SetProps(props);
    }
    else {
        // If the format does not exist, apply the format name only.
        pgf.Name = name;
     }
}

Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 01, 2012 Mar 01, 2012

Copy link to clipboard

Copied

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?

Jason

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2012 Mar 02, 2012

Copy link to clipboard

Copied

LATEST

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.

Rick

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines