FrameScript - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

FrameScript

Description:

This script lists all the Graphic insets along with the associated file names ... IF gph.objectname = 'Inset' NEW Paragraph NewVar(CurrPgfNew) PrevObject(CurrPgf) ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 47
Provided by: Bil9117
Category:

less

Transcript and Presenter's Notes

Title: FrameScript


1
FrameScript
  • An Introduction

2
What is FrameScript?
  • Scripting language that lets you manipulate
    FrameMaker objects
  • Add-on that lets you automate FrameMaker
    functions
  • Licensed to one copy of FrameMaker

3
What is FrameScript?
  • FrameScript files are .fsl files (text files you
    can create using Notepad).
  • Script is interpreted by FrameScript, and not
    compiled as a .dll.
  • FrameScript is inexpensive (150).
  • Focused on high-level users, not programmers.

4
What can you do with it?
  • Customize FrameMaker with script commands
  • Create new FrameMaker functions
  • Combine two or more current functions into one
    command
  • Create functions that used to require computer
    programmers

5
What can you do with it?
  • You can create commands to
  • Create, save, open, and close documents and books
  • Create and delete FrameMaker objects (tables,
    anchored frames, variables, markers, etc.)
  • Set the properties of FrameMaker objects
  • Create menu and menu items
  • Automatically respond to an event (run commands
    every time you close a document, or when you
    close FrameMaker)

6
What can you do with it?
  • You can create commands to
  • Create loops and IF-THEN-ELSE commands for
    testing and controlling a script
  • Create scripts that display and respond to
    standard FrameMaker dialog boxes (cutting and
    pasting text objects, inserting or deleting text,
    etc.)
  • AND MORE...

7
What can you do with it?
  • Use scripts to
  • Customize FrameMaker
  • Add functions to FrameMaker
  • Automate tasks
  • Build custom reports

8
What can you do with it?
9
Who can use it?
  • Windows
  • Version 2.1 for Frame 5.5 7
  • Mac
  • Version 2.0 for Frame 5.56 7
  • Frame Development Kit

10
So, Whats a Script?
  • Set Displaying True
  • Update ReDisplay
  • If (ActiveDoc)
  • If (Not ActiveDoc.DocIsViewOnly)
  • Set ActiveDoc.StatusLine ''
  • EndIf
  • EndIf
  • If (ActiveBook)
  • If (Not ActiveBook.BookIsViewOnly)
  • Set ActiveBook.StatusLine ''
  • EndIf
  • EndIf

11
So, Whats a Script?
  • Set Displaying True
  • Update ReDisplay
  • If (ActiveDoc)
  • If (Not ActiveDoc.DocIsViewOnly)
  • Set ActiveDoc.StatusLine ''
  • EndIf
  • EndIf
  • If (ActiveBook)
  • If (Not ActiveBook.BookIsViewOnly)
  • Set ActiveBook.StatusLine ''
  • EndIf
  • EndIf

This script refreshes the screen after a script
is aborted.
12
So, Whats a Script?
  • Scripts can be
  • Standalone scripts run as needed (evoke from the
    FrameScript menu).
  • Event-driven to enhance FrameMaker (installed as
    scripts, evoke from FrameMaker menu).

13
Scripting Basics
  • Begin with a very good idea of the problem the
    script will solve

14
Scripting Basics
  • Begin with a very good idea of the problem the
    script will solve
  • Develop a basic script that solves part of the
    problem (iterative development)

15
Scripting Basics
  • Begin with a very good idea of the problem the
    script will solve
  • Develop a basic script that solves part of the
    problem (iterative development)
  • Test the script against a sample file

16
Scripting Basics
  • Begin with a very good idea of the problem the
    script will solve
  • Develop a basic script that solves part of the
    problem (iterative development)
  • Test the script against a sample file
  • Review the results for accuracy

17
Scripting Basics
  • Begin with a very good idea of the problem the
    script will solve
  • Develop a basic script that solves part of the
    problem (iterative development)
  • Test the script against a sample file
  • Review the results for accuracy
  • Correct the script

18
Scripting Basics
  • Revise

19
Scripting Basics
  • Revise
  • Test

20
Scripting Basics
  • Revise
  • Test
  • Complete

21
Scripting Basics
  • Revise
  • Test
  • Complete

22
Scripting Basics
  • Revise
  • Test
  • Complete
  • Compile

23
Scripting Basics
  • Revise
  • Test
  • Complete
  • Compile
  • Test

24
Scripting Basics
  • Revise
  • Test
  • Complete
  • Compile
  • Test
  • Deploy

25
Scripting Basics
26
FrameScript Commands
  • Add an object to a menu
  • Add CmdObject(cmdvar) To(Menuobjectvar)
  • Add a member to a list
  • Add Member(membervalue) To(listvar)After(memberN
    umber) Before(memberNumber)

27
FrameScript Commands
  • Set the text properties for a range of text
  • Apply TextProperties Properties(propvar)
    DocObject(docobject) or TextRange(rangevar)
    and/orCondFmt(conditionformatname)
    CondFmt(condname) ...
  • Copy the current selection to the clipboard
  • Copy Text DocObject(docvar)Interactive
    VisibleOnly

28
FrameScript Commands
  • Delete columns from a table
  • Delete TableColumns TableObject(tablevar)StartCol
    (startcolumnnumber) NumCols(numberofcolumns)
  • Delete rows from a table
  • Delete TableRows TableObject(tablevar)RowObject(r
    owvar) NumRows(numberofrows)

29
FrameScript Commands
  • Display a dialog box to select from a list from
    the file system
  • DialogBox Type(ChooseFile) Directory(dirname)
    Title(dialogTitle)Init(InitialString)Mode(S
    electFile OpenFile SaveFile OpenDirectory)NewVar
    (varname) Button(varname)

30
FrameScript Commands
  • Create and inserts a table in the selected
    location
  • New Table NewVar(varname) DocObject(docvar)
    or TextLoc(locvar)Format(formatname)NumCols(
    numberofcolumns)BodyRows(num)HeaderRows(num)
    FooterRows(num)

31
FrameScript Commands
  • Creates a new FrameMaker document
  • New DocumentTemplate(filename)orPortrait or
    LandscapeorWidth(metricvalue)
    Height(metricvalue) NumCols(intvalue)Columngap(me
    tricvalue) TopMargin(metricvalue)Bottommargin(met
    ricvalue)LeftInsideMargin(metricvalue)
    RightOutsideMargin(metricvalue)SingleSided
    FirstPageRight FirstPageLeft InvisibleNewVar(
    docvar)

32
Sample Scripts
33
Sample Scripts
  • IF ActiveDoc 0
  • MSGBOX 'No Active Document'
  • LEAVESUB
  • ENDIF
  • SET SrcDoc ActiveDoc
  • NEW Document NewVar(docvar) Portrait
  • // Get paragraph formats for output
  • GET Object Type(PgfFmt) NewVar(h1)
    Name('Heading1')
  • GET Object Type(PgfFmt) Newvar(bodyfmt)
    Name('Body')
  • SET CurrPgf docvar.MainFlowInDoc

This script lists all the Graphic insets along
with the associated file names (if imported by
reference).
34
Sample Scripts
  • NEW Paragraph NewVar(CurrPgfNew)
    PrevObject(CurrPgf)
  • SET CurrPgf CurrPgfNew
  • SET CurrPgf.Properties h1.Properties //
    Apply Heading1 pgffmt
  • NEW Text Object(CurrPgf) 'List of Graphic
    Insets'
  • SET gph SrcDoc.FirstGraphicInDoc
  • LOOP while (gph)
  • IF gph.objectname 'Inset'
  • NEW Paragraph NewVar(CurrPgfNew)
    PrevObject(CurrPgf)
  • SET CurrPgf CurrPgfNew
  • SET CurrPgf.Properties bodyfmt.Properties
    // Apply Body pgffmt
  • IF gph.InsetFile.objectsize gt 0
  • NEW Text Object(CurrPgf) 'Image
    ('gph.InsetFile')'
  • ELSE
  • NEW Text Object(CurrPgf) 'Image
    (BYCOPY)'
  • ENDIF
  • ENDIF
  • SET gph gph.NextGraphicInDoc
  • ENDLOOP

35
Sample Scripts
  • DIALOGBOX Type(ChooseFile) Title('Select a
    directory')
  • Mode(OpenDirectory) Button(btnvar)
    NewVar(dirvar)
  • IF btnvar CANCELBUTTON
  • LEAVESUB
  • ENDIF
  • SET dirpath dirvar
  • SET totalFileCount 0
  • SET fmFileCount 0
  • SET pdfFileCount 0
  • LOOP ForEach(File) In(dirpath) LoopVar(fname)
  • SET totalFileCount totalFileCount 1
  • Find '.fm' InString(fname) Suffix
    ReturnStatus(SuffixFound)
  • IF SuffixFound
  • SET fmFileCount fmFileCount 1
  • RUN OpenAndSaveIt DocFileName(fname)
  • ENDIF
  • ENDLOOP

This script opens all the FrameMaker files in a
directory and saves them as PDF files.
36
Sample Scripts
  • MSGBOX 'Complete 'CHARLFtotalFileCount' Total
    Files '
  • CHARLFfmFileCount' fm Files '
  • CHARLFpdfFileCount' pdf Files
    created'
  • SUB OpenAndSaveIt using DocFileName
  • RUN isDocOpenAlready FileName(DocFileName)
    returns DocObj(docVar)
  • IF docVar 0
  • SET AlreadyOpen False
  • SET errorcode 0
  • OPEN Document File(DocFileName) Invisible
    FileIsOldVersion FontNotFoundInDoc
    NewVar(docVar)
  • IF ErrorCode not 0
  • DISPLAY 'Error Opening
    Document-'DocFileName' Msg-'ErrorMsg
  • ENDIF
  • ELSE
  • SET AlreadyOpen True
  • ENDIF

37
Sample Scripts
  • IF docVar not 0
  • RUN GetNewFileSuffix InFileName(DocFileName)
    NewSuffix('pdf') returns OutFileName(ofilename)
  • SET errorcode 0
  • SAVE Document DocObject (docVar)
    File(ofilename) FileType(SaveFmtPdf)
  • IF ErrorCode not 0
  • DISPLAY 'Save to PDF Failed
    errorcode'ErrorCode' Msg'ErrorMsg
  • ELSE
  • WRITE console 'Document
    ('DocFileName') saved as 'ofilename
  • SET pdfFileCount pdfFileCount 1
  • ENDIF
  • IF AlreadyOpen False
  • CLOSE Document DocObject(docVar)
    IGNOREMODS
  • SET docVar 0
  • ENDIF
  • ENDIF
  • ENDSUB

38
Sample Scripts
  • //------------------------------------------------
    ----------------------------
  • // This subroutine checks the list of open
    documents to see if the
  • // specified document is already open.
  • // Format
  • // Run IsDocAlreadyOpen Filename(testfilenam
    e) returns DocObj(retdocvar)
  • // If it is open, it returns the document
    object
  • // and returns zero if it is not open.
  • //------------------------------------------------
    ----------------------------
  • SUB isDocOpenAlready using filename DocObj
  • GET String FromString (filename) Uppercase
    NewVar(tfilename) // Upper case the string
  • SET DocObj 0
  • LOOP foreach(Doc) In(Session)
    LoopVar(testdocobj)
  • GET String FromString (testdocobj.Name)
    Uppercase NewVar(tname) // Upper case the string
  • IF tname tfilename
  • SET DocObj testdocobj
  • LEAVELOOP
  • ENDIF
  • ENDLOOP
  • ENDSUB

39
Sample Scripts
  • SUB GetNewFileSuffix using InFileName NewSuffix
    returns OutFileName
  • SET SuffixDotPosition -1
  • SET SuffixFound 0
  • FIND '.' InString(InFileName) Back
    ReturnPos(SuffixDotPosition) ReturnStatus(SuffixFo
    und)
  • IF SuffixFound
  • GET String FromString(InFileName)
    EndPos(SuffixDotPosition) NewVar(OutFileName)
  • SET OutFileName OutFileName NewSuffix
  • ELSE
  • SETOutFileName OutFileName '.'
    NewSuffix
  • ENDIF
  • Delete Var(dotpos)
  • Delete Var(SuffixFound)
  • ENDSUB

40
Sample Scripts
  • IF ActiveDoc 0
  • MSGBOX 'No Active Document'
  • LEAVESUB
  • ENDIF
  • // Get all paragraph format names from the
    catalog
  • NEW StringList NewVar(plist)
  • NEW IntList NewVar(ilist)
  • LOOP ForEach(PgfFmt) In(ActiveDoc)
    LoopVar(XPgfObj)
  • ADD Member(XPgfObj.Name) To(plist)
  • ADD Member(0) To(ilist)
  • ENDLOOP
  • SET srcDoc ActiveDoc

This script gives you a list of all paragraph
formats in the active document along with each
formats usage counts.
41
Sample Scripts
  • // Go through each paragraph in the document and
    update the count
  • LOOP ForEach(Pgf) In(ActiveDoc) LoopVar(pgfobj)
  • IF pgfobj.Page.ObjectName 'BodyPage' //
    Change only pgfs on body pages
  • FIND Member(pgfobj.Name) InList(plist)
    returnpos(rpos) returnstatus(rstat)
  • IF rstat not 0
  • GET Member Number(rpos) From(ilist)
    NewVar(holdcount)
  • IF holdcount lt 0
  • SET holdcount holdcount - 1
  • ELSE
  • SET holdcount holdcount 1
  • ENDIF
  • REPLACE Member Number(rpos) In(ilist)
    With(holdcount)
  • ELSE // Add pgffmt if not already present
  • ADD Member (pgfobj.Name) To(plist)
  • ADD Member (-1) To(ilist)
  • ENDIF
  • ENDIF
  • ENDLOOP

42
Sample Scripts
  • // Create new document for output
  • NEW Document NewVar(docvar) Portrait
  • SET CurrPgf docvar.MainFlowInDoc
  • SET hlistcount plist.objectsize
  • // Get paragraph formats for output
  • GET Object Type(PgfFmt) NewVar(h1)
    Name('Heading1')
  • GET Object Type(PgfFmt) Newvar(bodyfmt)
    Name('Body')
  • // Get a list of font names from Frame
  • SET tfonts FontFamilyNames
  • // Create first paragraph and insert heading
  • NEW Paragraph NewVar(CurrPgfNew)
    PrevObject(CurrPgf)
  • SET CurrPgf CurrPgfNew
  • SET CurrPgf.Properties h1.Properties //
    Apply Heading1 pgffmt
  • NEW Text Object(CurrPgf) 'List of Paragraph
    Formats

43
Sample Scripts
  • // Go through each member of the list and write
    out the entry
  • LOOP LoopVar(tidx) InitVal(1) Incr(1)
    While(tidxlthlistcount)
  • GET Member Number(tidx) From(plist)
    NewVar(hname)
  • GET Member Number(tidx) From(ilist)
    NewVar(hcount)
  • GET Object DocObject(srcDoc) Type(PgfFmt)
    Name(hname) NewVar(XPgfObj)
  • IF hcount lt 0
  • SET hcount -hcount
  • SET hname ''hname
  • ENDIF
  • NEW Paragraph NewVar(CurrPgfNew)
    PrevObject(CurrPgf)
  • SET CurrPgf CurrPgfNew
  • SET CurrPgf.Properties bodyfmt.Properties
    // Apply Body pgffmt

44
Sample Scripts
  • // Get font name
  • IF XPgfObj 0 // Paragraph format is not in
    catalog
  • SET hfname '???'
  • SET fontidx 0
  • ELSE
  • SET fontidx XPgfObj.FontFamily
  • GET Member Number(fontidx1) From(tfonts)
    NewVar(hfname)
  • ENDIF
  • NEW Text Object(CurrPgf) tidx'.
    Count'hcount' Name'hname' Font'hfname
  • ENDLOOP

45
Where do I get FrameScript?
  • Finite Matters, Inc
  • http//www.framescript.com/default.htm

46
Other Useful Links
  • FrameScript tutorials
  • http//www.frameexpert.com/tutorials/
  • FrameScript Syntax Definitions
  • http//www.techdoc.de/framescript/fs.syn
  • FrameScript Resources and Scripts
  • http//members.shaw.ca/philip.sharman/FrameScript.
    htm
Write a Comment
User Comments (0)
About PowerShow.com