Skip to main content
manishk88663184
Participating Frequently
Jul 5, 2019 5:58 AM UTC
Question

Conversion to Extends Script from FrameScript

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

This topic is closed to new replies. Start a new post to keep the conversation going.

6 replies

Inspiring
Jul 5, 2019 7:47 AM UTC

Quitt Session => app.Close

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

Markus

Translate
manishk88663184
Participating Frequently
Jul 7, 2019 6:31 PM UTC

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

Translate
Inspiring
Jul 9, 2019 5:24 PM UTC

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.

Translate