Script Help/Question
I'm trying to teach myself to script. I have a basic understanding of programming syntax and a passing familiarity with basic JavaScript, but I'm pretty much learning on the go.
My goal is to write a script that steps through each table in a document and modifies various settings of each. The first part of the script is borrowed directly from the second example script of the Adobe FrameMaker Scripting Guide (Ch 3, p. 8). The Tbl properties I took from the same doc (Ch 5, p. 523).
When I run the script in the ExtendScript Toolkit, the script executes without error, but none of the settings are applied in my open Frame document (i.e., all of the tables appear as they did before I ran the script).
I'm not sure why it's not working. The documentation available (PDFs and Object Model Viewer) are pretty opaque, and there's very little in the way of explanatory information to help me connect the pieces. I'm guessing I'm out of my depth, but I'd really like to gain proficiency; I'm just not sure how/where to start in general, or how to evaluate deficits in this current project in particular.
I'd very much appreciate any help this fantastic community can offer. Thank you for your time and patience!
---
var doc = app.ActiveDoc;
if(doc.ObjectValid() == true) {
var flow = doc.MainFlowInDoc;
var tbl = 0;
var textItems = flow.GetText(Constants.FTI_TblAnchor);
for (var i = 0; i < textItems.len; i += 1) {
tbl = textItems[i].obj;
tbl.ContentHeight = 2;
tbl.OrphanRows = 2;
tbl.TblCellBottomMargin = 2;
tbl.TblCellLeftMargin = 2;
tbl.TblCellTopMargin = 2;
tbl.TblAlignment = 0;
tbl.TblPlacement = 5;
tbl.TblSpaceAbove = 15;
tbl.TblSpaceBelow = 15;
tbl.TblWidth = 6;
tbl.TblBodyRowRulingPeriod = 1;
tbl.TblBodyRowRuling.Pen = 0;
tbl.TblBodyRowRuling.RulingPenWidth = 0.4;
tbl.TblTopRuling.Pen = 0;
tbl.TblTopRuling.RulingPenWidth = 1.5;
tbl.TblBottomRuling.Pen = 0;
tbl.TblBottomRuling.RulingPenWidth = 1.5;
}
}
--
Note, there may be an easier way to do this--for example by just applying an existing Table style to every table in a doc, which would also work. Just not sure whether that's possible or how to do it.



