programming4us
 
Graphics
 

Adobe InDesign CS5 : Using Scripts - Exploring JavaScript

2/4/2012 3:59:22 PM

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
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
 
Top 10
 
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8
- How To Get Microsoft Office 2013 Trial Product Key From Microsoft
- Complete List Of Windows 8 Keyboard Shortcuts [Hotkeys]
- How To Bypass Torrent Connection Blocking By Your ISP