Walking through the script. Adobe InCopy CS6
Add to My manuals108 Pages
Adobe® InCopy® CS6 empowers copywriters and editors to collaborate seamlessly on copy-intensive projects with designers using Adobe® InDesign®. With InCopy, you can write, edit, and style text in a copyflow workspace that’s specifically designed for editorial workflows. Plus, you can easily integrate with InDesign to place and edit copy within page layouts. Whether you’re working on a magazine, newspaper, or marketing collateral, InCopy can help you create high-quality copy efficiently and effectively.
advertisement
![Walking through the script. Adobe InCopy CS6 | Manualzz Walking through the script. Adobe InCopy CS6 | Manualzz](http://s3.manualzz.com/store/data/053735945_1-62d2bfb0177c558e8e074a39acf5ba05-360x466.png)
Getting Started Scripting terminology and the InCopy object model 14
Walking through the script
Here is a step-by-step analysis of what the Hello World script does.
1.
Establish communication with the InCopy application object:
Set myInCopy = CreateObject("InCopy.Application")
2.
Create a new document and a reference to the document:
Set myDocument = myInCopy.Documents.Add
3.
Get a reference to the first story in the document (a standalone document always contains a story):
Set myStory = myDocument.Stories.Item(1)
4.
Add text to the story by setting the contents property to a string.
myStory.Contents = "Hello World!"
Scripting terminology and the InCopy object model
Now that you created your first InCopy script, it is time to learn more about the terminology of scripting languages in general and InCopy scripting in particular.
Scripting terminology
First, let’s review a few common scripting terms and concepts.
Comments
Comments give you a way to add descriptive text to a script. The scripting system ignores comments as the script executes; this prevents comments from producing errors when you run your script. Comments are useful when you want to document the operation of a script (for yourself or someone else). In this document, we use comments in the tutorial scripts.
To include a comment in VBScript, type
Rem
(for “remark”) or
'
(one straight quote) to the left of the comment. To make an entire line a comment, type the comment marker at the beginning of a line. For example:
Rem this is a comment
' and so is this
Values
The point size of a text character, the contents of a note, and the filename of a document are examples of values used in InCopy scripting. Values are the data your scripts use to do their work.
The type of a value defines what sort of data the value contains. For example, the value type of the contents of a word is a text string; the value type of the leading of a paragraph is a number. Usually, the values used in scripts are numbers or text. The following table explains the value types most commonly used in InCopy scripting:
Getting Started Scripting terminology and the InCopy object model 15
Value Type
Boolean
Integer
Double
String
Array
What it is
Logical True or False.
Example
True
Whole numbers (no decimal points). Integers can be positive or negative.
A high-precision number that can contain a decimal point.
14
13.9972
A series of text characters. Strings appear inside (straight) quotation marks.
A list of values (the values can be any type).
"I am a string"
Array("0p0", "0p0", "16p4", "20p6")
Converting values from one type to another
VBScript provides ways to convert variable values from one type to another. The most common converstions involved converting numbers to strings (so you can enter them in text or display them in dialogs) or converting strings to numbers (so you can use them to set a point size or page location).
Rem To convert from a number to a string: myNumber = 2 myString = cstr(myNumber)
Rem To convert from a string to an integer: myString = "2" myNumber = cInt(myString)
Rem If your string contains a decimal value, use "cDbl" rather than "cInt": myNumber = cDbl(myString)
Variables
A variable is a container for a value. They are called “variables” because the values they contain might change. A variable might hold a number, a string of text, or a reference to an InCopy object. Variables have names, and you refer to a variable by its name. To put a value into a variable, you assign the data to the variable.
In all examples and tutorial scripts that come with InCopy, all variables start with my . This enables you to easily differentiate variables we created in a script from scripting-language terms.
Assigning a value to a variable
Assigning values or strings to variables is fairly simple, as shown in these examples: myNumber = 10 myString = "Hello, World!"
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
Try to use descriptive names for your variables, like firstPage or corporateLogo , rather than x or c . This makes your script easier to read. Longer names do not affect the execution speed of the script.
Getting Started Scripting terminology and the InCopy object model 16
Variable names must be one word, but you can use internal capitalization (like myFirstPage
) or underscore characters ( my_first_page
) to create more readable names. Variable names cannot begin with a number, and they cannot contain punctuation or quotation marks.
Array variables
An Array is a container for a series of values: myArray = Array(1, 2, 3, 4)
Rem In Visual Basic.NET: myArray = New Double (1, 2, 3, 4)
To refer to an item in an array, refer to its index in the array.In VBScript, the first item in an array is item 0: myFirstArrayItem = myArray(0)
N OTE : The Visual Basic
OptionBase
statement can be used to set the first item of an array to item 1. In the examples in this document, the first item in an array is item 0, not item 1, because that is the default. If you set OptionBase to 1, you must adjust all array references in the sample scripts accordingly.
Arrays can include other arrays, as shown in the following examples: myArray = Array(Array(0,0), Array(72, 72))
Rem In Visual Basic.NET: myArray = New Array(New Double(0,0), NewDouble (0,0))
Finding the value type of a variable
Sometimes, your scripts must make decisions based on the value type of an object. If you are working on a script that operates on a text selection, for example, you might want that script to stop if nothing is selected.
Rem Given a variable of unknown type, "myMysteryVariable"...
myType = TypeName(myMysteryVariable)
Rem myType will be a string corresponding to the variable type (e.g., "Rectangle")
Operators
Operators use variables or values to perform calculations (addition, subtraction, multiplication, and division) and return a value. For example:
MyWidth/2 returns a value equal to half of the content of the variable myWidth
.
You also can use operators to perform comparisons (equal to ( = ), not equal to( <> ), greater than ( > ), or less than (
<
)). For example:
MyWidth > myHeight returns the value true
(or 1) if myWidth
is greater than myHeight
; otherwise, false
(0).
In VBScript, use the ampersand (
&
) to concatenate (or join) two strings. For example:
"Pride " & "and Prejudice" returns the string:
"Pride and Prejudice"
advertisement
Key Features
- Seamless collaboration between copywriters and designers
- Copyflow workspace tailored for editorial workflows
- Effortless integration with InDesign for copy placement and editing
- Comprehensive text editing and styling capabilities
- Efficient handling of long-form and complex documents
- Streamlined copyfitting and typesetting features
- Advanced typography controls for precise text formatting
Related manuals
Frequently Answers and Questions
Can InCopy be used independently of InDesign?
How does InCopy integrate with InDesign?
What are the benefits of using InCopy for editorial workflows?
Does InCopy support advanced typography features?
advertisement
Table of contents
- 7 Introduction
- 7 How to use the scripts in this document
- 7 About the structure of the scripts
- 8 For more information
- 8 About InCopy
- 8 Relationships between InCopy and InDesign files
- 8 Stories
- 9 Page geometry
- 9 Metadata
- 9 The document model
- 10 User-interface differences
- 10 Design and architecture
- 11 Getting Started
- 11 Installing scripts
- 12 Running scripts
- 12 Using the scripts panel
- 12 VBScript language details
- 13 Using the scripts in this document
- 13 Your first InCopy script
- 14 Walking through the script
- 14 Scripting terminology and the InCopy object model
- 14 Scripting terminology
- 17 Understanding the InDesign and InCopy object model
- 23 Measurements and positioning
- 24 Adding features to “Hello World
- 26 Scripting Features
- 26 Script preferences
- 27 Getting the current script
- 27 Script versioning
- 28 Targeting
- 28 Compilation
- 28 Interpretation
- 29 Using the DoScript method
- 29 Sending parameters to DoScript
- 29 Returning values from DoScript
- 30 Running scripts at start-up
- 31 Text and Type
- 31 Entering and importing text
- 31 Stories and text frames
- 31 Adding text to a story
- 32 Replacing text
- 32 Inserting special characters
- 33 Placing text and setting text-import preferences
- 37 Exporting text and setting text-export preferences
- 40 Text objects
- 41 Selections
- 42 Moving and copying text
- 43 Text objects and iteration
- 44 Formatting text
- 44 Setting text defaults
- 47 Fonts
- 48 Applying a font
- 48 Changing text properties
- 49 Changing text color
- 50 Creating and applying styles
- 51 Deleting a style
- 52 Importing paragraph and character styles
- 52 Finding and changing text
- 52 Find/change preferences
- 53 Finding text
- 54 Finding and changing formatting
- 55 Using grep
- 57 Using glyph search
- 57 Tables
- 60 Autocorrect
- 61 Footnotes
- 62 User Interfaces
- 62 Dialog-box overview
- 64 Your first InCopy dialog box
- 64 Adding a user interface to “Hello World
- 65 Creating a more complex user interface
- 67 Working with ScriptUI
- 68 Creating a progress bar with ScriptUI
- 68 Creating a button-bar panel with ScriptUI
- 71 Menus
- 71 Understanding the menu model
- 73 Localization and menu names
- 74 Running a menu action from a script
- 74 Adding menus and menu items
- 75 Menus and events
- 76 Working with script menu actions
- 78 Events
- 78 Understanding the event scripting model
- 80 About event properties and event propagation
- 81 Working with eventListeners
- 83 A sample “afterNew” eventListener
- 85 Notes
- 85 Entering and importing a note
- 85 Adding a note to a story
- 85 Replacing text of a note
- 86 Converting between notes and text
- 86 Converting a note to text
- 86 Converting text to a note
- 86 Expanding and collapsing notes
- 86 Collapsing a note
- 86 Expanding a note
- 87 Removing a note
- 87 Navigating among notes
- 87 Going to the first note in a story
- 87 Going to the next note in a story
- 87 Going to the previous note in a story
- 88 Going to the last note in a story
- 89 Tracking Changes
- 89 Navigating tracked changes
- 90 Accepting and reject tracked changes
- 90 Information about tracked changes
- 91 Preferences for tracking changes
- 94 Assignments
- 94 Assignment object
- 94 Opening assignment files
- 94 Iterating through assignment properties
- 95 Assignment packages
- 95 An assignment story
- 95 Assigned-story object
- 95 Iterating through the assigned-story properties
- 97 Overview
- 97 The best approach to scripting XML in InCopy
- 98 Scripting XML Elements
- 98 Setting XML preferences
- 98 Setting XML import preferences
- 99 Importing XML
- 99 Creating an XML tag
- 100 Loading XML tags
- 100 Saving XML tags
- 100 Creating an XML element
- 100 Moving an XML element
- 100 Deleting an XML element
- 101 Duplicating an XML element
- 101 Removing items from the XML structure
- 101 Creating an XML comment
- 101 Creating an XML processing instruction
- 102 Working with XML attributes
- 102 Working with XML stories
- 103 Exporting XML
- 103 Adding XML elements to a story
- 103 Associating XML elements with text
- 105 Applying styles to XML elements
- 106 Working with XML tables