IT tutorials
 
Graphics
 

Adobe InDesign CS5 : Using Scripts - Exploring JavaScript

2/4/2012 3:59:22 PM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

JavaScript is a scripting language developed by Netscape Communications, based on Sun Microsystems's Java language that was meant to let Web browsers manage resources on far-flung servers by running scripts to control the servers from a desktop. JavaScript soon became a popular scripting language because, as does Java, it runs on so many types of computers, including Windows, Mac, and Unix. But because it is based largely on the object-oriented approach taken by professional computer languages such as C and C++, it can be difficult for nonprogrammers to use.

There are lots of JavaScript editor programs available. Most of these are developed by individuals and small firms, so the list is always changing. I recommend you use the Google search engine (www.google.com) and search for JavaScript editor to find the most current programs. A great script-editing program for Mac users is Bare Bones Software's venerable BBEdit; you can get more information at www.barebones.com.

1. Learning the language

JavaScript is a very complex language based on object-oriented programming, which abstracts items and attributes as objects that are then grouped, changed, or otherwise manipulated. This means that JavaScript is less English-like than other scripting languages because it requires you to spend a fair amount of time setting up the objects before you can manipulate them.

myObject.strokeTint = newValue;

This example shows that there is a current object named strokeTint being set to a new value; the actual value for newValue is set earlier in the script.

2. What you need to write and run scripts

You need a program that can display, edit, and test your JavaScript; there is no bundled JavaScript editor in Windows or Mac OS X. Such editors typically format the JavaScript code for you, indenting it automatically, graying out comments, and highlighting certain keywords.

You can use a word processor or text editor to write and edit scripts, but such programs can't check the syntax or automatically format the script text to help show nested loops, conditional branches, and so on. Also, you can usually use an HTML editor such as Adobe Dreamweaver in which to edit JavaScripts, though they also typically don't provide any debugging tools to help you track and fix coding (syntax) errors. (Figure 37.2 shows a JavaScript script being edited in Dreamweaver.) In this case, you need to open the error window in your browser as you test the code and see if it identifies the error location to help you find it in your HTML editor.

Getting More Information on JavaScript

Before you venture too far into scripting, you should review the JavaScript-related information provided with InDesign:

  • JavaScript documentation and tools: Sun places the very technical JavaScript documentation on its Web site at http://java.sun.com/javascript/index.jsp.

  • InDesign scripting documentation: The InDesign installation DVD contains a 2,000-plus-page PDF file that explains scripting for InDesign. This document, although a bit on the technical side, is a valuable resource. It includes an overview of JavaScript scripting and the object model, as well as a list of InDesign-specific scripting terms and scripting examples.


Figure 1. A JavaScript program viewed in Adobe Dreamweaver

2.1. Running your script

The easiest way to run a script is to double-click it in the Scripts panel within InDesign, but you also can simply double-click the script file; note that InDesign may need to be open. Also, while you're developing the script, you can run the script directly from the application in which you created it — again, InDesign may need to be open. If you've done everything correctly, you see

InDesign become the active program, and then the actions you put in your script take place. Voilà and congratulations! You can now call yourself a scripter without blushing. That's all there is to creating and running a script.

2.2. Saving your script

When you're finished writing and testing a script, choose Save from the script editor's File menu. Name your script and choose its storage location. Move or copy the saved script to one of the two locations .

 
Others
 
- Adobe InDesign CS5 : Using Scripts & Script tips
- Adobe Flash Catalyst CS5 : Changing stroke and fill (part 2) - Change stroke color and weight, Add and modify gradient fills
- Adobe Flash Catalyst CS5 : Changing stroke and fill (part 1) - Change the fill color
- Adobe Illustrator CS5 : Working with Layers - Showing and Hiding Layers and Objects, Merging Layers and Groups
- Adobe Illustrator CS5 : Working with Layers - Duplicating Layers and Objects, Locking Layers and Objects
- Dreamweaver CS5 : Editing Content in the Browser (part 2) - Registering an InContext Editing site & Making edits online
- Dreamweaver CS5 : Editing Content in the Browser (part 1) - Setting up InContext Editing templates
- Dreamweaver CS5 : Using Dreamweaver Templates - Updating Templates & Removing Template Markup
- Adobe Photoshop CS5 : Fixing Problems Caused by Your Camera’s Lens
- Adobe Photoshop CS5 : Removing Tourists the Easy Way
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us