Highlighted

Conversion to Extends Script from FrameScript

New Here ,
Jul 04, 2019

Copy link to clipboard

Copied

Hi, I want to convert my frameScript code into extends script. And as we know in frameScript most of the functions are predefined and i am not able to find the alternate of those function in ExtendScript
Please find my frameScript below

Set PlatformEncodingMode = True;

Set Displaying = 0;

Execute Fc KbdMinimize;

Set gvBookName       = Arg1;

Set gvMarkerFileName = Arg2;

Open Book File (gvBookName) NewVar(bookobj)

               BookIsInUse(ResetLockAndContinue)    

               FileIsInUse(ResetLockAndContinue)

               RefFileNotFound(Cancel)

               UpdateXRefs(No)

               ReturnFilename(returnFilename)

               FontNotFoundInDoc (OK)

               FileIsOldVersion (OK)

               AlertUserAboutFailure(False);

    Set ActiveBook = bookobj;

    write console 'book path'+returnFilename;

   Run eSys.ExtractPathName FullPath(returnFilename) NewVar(Pathname);

    Open Document File (Pathname+'2.CompilerProfile.fm') NewVar(docobj)

                       BookIsInUse(ResetLockAndContinue)    

                       FileIsInUse(ResetLockAndContinue)

                       RefFileNotFound(Cancel)

                       UpdateXRefs(No)

                       ReturnStatus(gvErrorList)

                       FontNotFoundInDoc (OK)

                       FileIsOldVersion (OK)

                       AlertUserAboutFailure(False);

    If ErrorCode = 0

       eStr.SaveToTextFile{' ', gvMarkerFileName};

        Set vDoc = ActiveDoc;

        Set vMarker = vDoc.FirstMarkerInDoc;

        Loop While (vMarker)

            If vMarker.MarkerTypeId.InvariantName = 'AutoEdoc'

                Find String ('ds2mif') InString(vMarker.MarkerText) ReturnStatus(gvfound);

                If gvFound = 1

                    Set tmp = eStr.ReplaceAll{vMarker.MarkerText, 'CR LF', ''};

                    Set vMarkerText = '{' + tmp  + '} ';

                    Write Console 'The current marker is '+vMarkerText;

                    Set gvIntVal = eStr.SaveToTextFile{vMarkerText, gvMarkerFileName, 'APPEND'};

                EndIf

            EndIf

            Set vMarker = vMarker.NextMarkerInDoc;

        EndLoop

        Close Document DocObject(docobj) IgnoreMods;

   EndIf

Close Book BookObject(bookobj) IgnoreMods;

Quit Session;

The highlighted texts are the built-in function in FrameScript my question is are the same in extendScript as well?

I am very new at extendScript. Can anyone suggest me how can I write this script into ExtendScript?


Also, anyone has any study material in this please share it with me at my email: manish13102373@gmail.com.

Thanks,
Manish

TOPICS
Scripting

Views

652

Likes

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

Conversion to Extends Script from FrameScript

New Here ,
Jul 04, 2019

Copy link to clipboard

Copied

Hi, I want to convert my frameScript code into extends script. And as we know in frameScript most of the functions are predefined and i am not able to find the alternate of those function in ExtendScript
Please find my frameScript below

Set PlatformEncodingMode = True;

Set Displaying = 0;

Execute Fc KbdMinimize;

Set gvBookName       = Arg1;

Set gvMarkerFileName = Arg2;

Open Book File (gvBookName) NewVar(bookobj)

               BookIsInUse(ResetLockAndContinue)    

               FileIsInUse(ResetLockAndContinue)

               RefFileNotFound(Cancel)

               UpdateXRefs(No)

               ReturnFilename(returnFilename)

               FontNotFoundInDoc (OK)

               FileIsOldVersion (OK)

               AlertUserAboutFailure(False);

    Set ActiveBook = bookobj;

    write console 'book path'+returnFilename;

   Run eSys.ExtractPathName FullPath(returnFilename) NewVar(Pathname);

    Open Document File (Pathname+'2.CompilerProfile.fm') NewVar(docobj)

                       BookIsInUse(ResetLockAndContinue)    

                       FileIsInUse(ResetLockAndContinue)

                       RefFileNotFound(Cancel)

                       UpdateXRefs(No)

                       ReturnStatus(gvErrorList)

                       FontNotFoundInDoc (OK)

                       FileIsOldVersion (OK)

                       AlertUserAboutFailure(False);

    If ErrorCode = 0

       eStr.SaveToTextFile{' ', gvMarkerFileName};

        Set vDoc = ActiveDoc;

        Set vMarker = vDoc.FirstMarkerInDoc;

        Loop While (vMarker)

            If vMarker.MarkerTypeId.InvariantName = 'AutoEdoc'

                Find String ('ds2mif') InString(vMarker.MarkerText) ReturnStatus(gvfound);

                If gvFound = 1

                    Set tmp = eStr.ReplaceAll{vMarker.MarkerText, 'CR LF', ''};

                    Set vMarkerText = '{' + tmp  + '} ';

                    Write Console 'The current marker is '+vMarkerText;

                    Set gvIntVal = eStr.SaveToTextFile{vMarkerText, gvMarkerFileName, 'APPEND'};

                EndIf

            EndIf

            Set vMarker = vMarker.NextMarkerInDoc;

        EndLoop

        Close Document DocObject(docobj) IgnoreMods;

   EndIf

Close Book BookObject(bookobj) IgnoreMods;

Quit Session;

The highlighted texts are the built-in function in FrameScript my question is are the same in extendScript as well?

I am very new at extendScript. Can anyone suggest me how can I write this script into ExtendScript?


Also, anyone has any study material in this please share it with me at my email: manish13102373@gmail.com.

Thanks,
Manish

TOPICS
Scripting

Views

653

Likes

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
Jul 04, 2019 0
Engaged ,
Jul 05, 2019

Copy link to clipboard

Copied

Quitt Session => app.Close

For other file related issues use File object, to work with filenames and writing text

Markus

Likes

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
Reply
Loading...
Jul 05, 2019 0
New Here ,
Jul 07, 2019

Copy link to clipboard

Copied

Okay But i want to run this script via command line and i have to open the frammaker file and then read all the markers, put their text into a txt file and then close it
is it possible in extendScript. Please suggest me some study material for extendScript.


Thanks

Likes

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
Reply
Loading...
Jul 07, 2019 0
Engaged ,
Jul 09, 2019

Copy link to clipboard

Copied

Hi,

you can implement an event driven script, with listens to Constants.FA_Note_PostOpenDoc/FA_Note_PostOpenBook.

You can register events with

Notification(Constants.FA_NotePostOpenDoc, true)

and listen to events with

function notify(note, object, sparam, iparam)

{

//your code

}

(more Information see https://help.adobe.com/en_US/framemaker/pdfs/framemaker_scripting.pdf on page 82)

Then you start FM with FM-book/-document as first Parameter, do what you want to do, and close document an session again.

Side note: the FM EULA doesn't allow to fully automate stuff without user interaction. please check if EULA works with these scenarios.

Likes

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
Reply
Loading...
Jul 09, 2019 0
New Here ,
Jul 09, 2019

Copy link to clipboard

Copied

Hi

I tried Notification function but getting an error that notfication function is not defined
Do we have to import any function here?

Likes

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
Reply
Loading...
Jul 09, 2019 0
Adobe Community Professional ,
Jul 10, 2019

Copy link to clipboard

Copied

Put this at the top of your script:

#target framemaker

Likes

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
Reply
Loading...
Jul 10, 2019 0
Community Beginner ,
Oct 24, 2019

Copy link to clipboard

Copied

I've started putting this in the top of my files instead, so that it is compatible with Visual Studio Code. It also seems to be compatible with Adobe Extendscript Toolkit:

 

 

//@target framemaker

 

 

Likes

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
Reply
Loading...
Oct 24, 2019 0