Adobe 27510753 Scripting Guide - Page 23
Control structures, Conditional statements
UPC - 718659445294
View all Adobe 27510753 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 23 highlights
Adobe InDesign CS2 Scripting Guide Scripting Basics 15 AppleScript In AppleScript, you can also use the "with properties" to specify object properties as the object is created. tell application "Adobe InDesign CS2" --Example of an optional parameter (requires that you have a document preset --named "7x9_book_cover"). set myDocument to make document with document preset "7x9_book_cover" tell page 1 of myDocument --Example of using "with properties" to specify object properties as you create the object. set myOval to make oval with properties {geometric bounds:{"6p", "6p", "18p", "18p"}} --Another "with properties" example. set myRectangle to make rectangle with properties {stroke weight:4} --Example of a required parameter: set myGroup to make group with properties {group items:{myOval, myRectangle}} end tell end tell VBScript Set myInDesign = CreateObject("InDesign.Application.CS2") Rem Example of an optional parameter (requires that you have Rem a document preset named "7x9_book_cover"). Set myDocument = myInDesign.Documents.Add(myInDesign.DocumentPresets.Item("7x9_book_cover")) Set myOval = myDocument.Pages.Item(1).Ovals.Add myOval.GeometricBounds = Array("6p", "6p", "18p", "18p") Set myRectangle = myDocument.Pages.Item(1).Rectangles.Add myRectangle.StrokeWeight = 4 Rem Example of a required parameter. Set myGroup = myDocument.Pages.Item(1).Groups.Add(Array(myOval, myRectangle)) JavaScript //Example of an optional parameter (requires that you have //a document preset named "7x9_book_cover"). var myDocument = app.documents.add(app.documentPresets.item("7x9_book_cover")) //Example of setting object properties as you create the object. var myOval = myDocument.pages.item(0).ovals.add( {geometricBounds:["6p", "6p", "18p", "18p"]}); var myRectangle = myDocument.pages.item(0).rectangles.add( {strokeWeight:4}); //Example of a required parameter. var myGroup = myDocument.pages.item(0).groups.add([myOval, myRectangle]); Control structures Most scripts do not proceed sequentially from beginning to end-they take different paths depending on decisions, or they repeat commands multiple times. Control structures are the commands to do such things. Conditional statements If you could talk to InDesign, you might say, "If the selected object is a rectangle, then set its stroke weight to 12 points." This is an example of a conditional statement. Conditional statements make decisions-they give your scripts a way to evaluate something (such as the color of the selected object, or the number of pages in the publication, or the date) and then act according to the result. Conditional statements almost always start with if. The following examples check the quantity of currently open publications. If no publications are open, the scripts display a message in a dialog box.