
10
ADOBE FRAMEMAKER SCRIPTING GUIDE
Differences between scripts and FDK
Last updated 9/26/2011
The same code can be written in scripts as follows:
doc.Capitalization = FV_CAPITAL_CASE_SMALL;
However, there is a separate class called
Constants
that can be used to access these Global Methods. The script code
can also be written as:
doc.Capitalization = Constants.FV_CAPITAL_CASE_SMALL;
Example 3:
Every FDK Structure such as
F_TextItemT
, and
F_TextLocT
are also mapped to objects in scripts. All the fields of
these structures are mapped to the read or write properties of these objects.
For example, structure
F_PointT
:
typedef struct {
MetricT x,y; /* The coordinate pair */
} F_PointT;
is mapped to the
Point
object in scripting. The
Point
object has two properties
x
and
y
.
See another FDK structure called
F_TextRangeT
:
typedef struct {
F_TextLocT beg; /* The beginning of the range */
F_TextLocT end; /* The end of the range */
} F_TextRangeT;
This structure is mapped to the
TextRange
object with both the properties
beg
and
end
being of type
TextLoc
.
Notice that F_TextLocT itself is another structure.
Note:
Structure objects do not have any methods associated with them.
The following example script fetches an Active Document and adds some text in the first paragraph of the first flow of
this document.
doc = app.ActiveDoc;
flow = doc.MainFlowInDoc;
textFrame = flow.FirstTextFrameInFlow;
pgf = textFrame.FirstPgf;
textLoc = new TextLoc();
textLoc.obj = pgf;
textLoc.offset = 0;
doc.AddText(textLoc, 'Sample Text');
Notice how the
F_TextLocT
FDK structure maps to the
TextLoc
object in scripts.
Lines 1, 2, 3, 4 can be combined and written as:
pgf = app.ActicveDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
Lines 6, 7, 8 can be combined and written by passing parameters in the constructor of the TextLoc object as:
textLoc = new TextLoc(pgf, 0);
Scripts have advanced features such as notifications and commands.