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

Need Help With Script Skipping Word Before Variable

Guest
Dec 17, 2013 Dec 17, 2013

Copy link to clipboard

Copied

I borrowed and modified a skip I found here: http://forums.adobe.com/message/4808804 with code borrowed from elsewhere.

I noticed that it seems to run fine, but it skips any word that appears right before a variable. The point of the script is to find any text using an italic override or bold override, and replace the override with the appropriate character format from the catalog.

Can someone tell me why the code below skips words before a variable? I am sure it is a simple thing, but I am teaching myself Extendscript, and only recently started the attempt/

Thanks,

Marc

var doc = app.ActiveDoc;

removeOverrides (doc)

function removeOverrides (pDoc)

{

    var vDocStart = pDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

    var vBoldFmt=pDoc.GetNamedCharFmt ('bold')

    var vItalicFmt=pDoc.GetNamedCharFmt ('italic')

    initFA_errno ();

    var vTextLoc = new TextLoc(vDocStart,0);

    var vFindParams=findOverrideParams (pDoc);

    while (FA_errno==Constants.FE_Success)

    {

        var vTextRange=pDoc.Find(vTextLoc,vFindParams);

        if (vTextRange.beg.obj.ObjectValid())

        {

            var vTextItems=pDoc.GetTextForRange (vTextRange, Constants.FTI_CharPropsChange)

            if (vTextItems.length==!0 )

            {

                $.writeln(vTextItems.String)

                if (vTextItems[0].idata==Constants.FTF_WEIGHT)

                {

                   pDoc.SetTextProps (vTextRange, vBoldFmt.GetProps())

                    }

                if (vTextItems[0].idata==Constants.FTF_ANGLE)

                {

                   pDoc.SetTextProps (vTextRange, vItalicFmt.GetProps())

                    }

                }// else (Log (vLogFileName, '\nERROR: No items were found in the text format array but format override was found: '+pDoc.Name))

            }

        vTextLoc = vTextRange.end

        vDocStart=vDocStart.NextPgfInFlow;

        }

}

function findOverrideParams (pDoc)

{

    var vFindParams = AllocatePropVals(1);

    vFindParams[0].propIdent.num = Constants.FS_FindObject;

    vFindParams[0].propVal.valType = Constants.FT_Integer;

    vFindParams[0].propVal.ival = Constants.FV_FindCharacterFormatOverride;

   return vFindParams;

   }

  function initFA_errno()

     {

         app.GetNamedMenu("!MakerMainMenu"); //If this fails, you've got bigger problems

         return;

         }

TOPICS
Scripting

Views

390

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
no replies

Have something to add?

Join the conversation