Developing ExtendScripts – Part 1


ExtendScripts automate tasks that you do in any of the TCS components. ExtendScripts are saved as .jsx file and are similar to JavaScript. TCS provides you with ExtendedScript ToolKit (ESTK) support to develop ExtendScripts.  ESTK is a development environment that makes the script development simpler.  In this first blog entry, I will familiarize you with ESTK. We will develop a simple JavaScript function using ESTK. 

I am not teaching you JavaScript here.  I assume that many of you are familiar with JavaScript. It doesn’t mean that you should have JavaScript development experience to code in ExtendedScript. However, that will help. I will not touch any TCS-specific codes here. This blog entry is just an introduction to ESTK.

Start

Open ESTK. (See the documentation if you do not know how to open ESTK.)

You see a blank screen titled, Source1. That’s your first file. You can start typing the code. You don’t need to save this file to run the code. (We will save the file later.)  

Let us start with a very simple example – a code that generates an alert. You know what an alert is, right? The pop-up that appears when you do something on a web page. Something similar to the one displayed below:

 

Start typing ‘alert’ in ESTK. Before you reach ‘l’ in ‘alert,’ you see a pop-up window that gives you a suggestion on what you are trying to type. It also provides you with an argument list that an alert statement takes.

Double-click it.  The following entry is inserted:

alert (message, title, errorIcon)

Run

Now, let’s run the code. It’s simple. Click the Play button displayed on the top-right corner. Oops!! You see that the code is highlighted in red. Observe that left-bottom corner displays a message saying, “message is undefined.” All JavaScript experts got the point. We have not defined the variable, “message.” So is the case with other variables – “title” and “errorIcon.” ESTK provided you the error the moment it detected “message.” It is yet to verify the other variables.  

Fix  

What to do next? Put all those variables in double quotes, so that ESTK knows they are just strings, not variables. Observe that the script has not completed execution. Click the Stop button in ESTK, and then insert the double quotes:  

alert (“message”, “title”, “errorIcon”)  

Now run it again. You got it right this time!! 

Explore  

Now let us make the alert statement a function and call it.

function showAlert(message, title, errorIcon) 
{
alert (message, title, errorIcon)
}  
showAlert(“It’s a message!!”, “Alert Title”, “errorIcon”)

We created a function showAlert that accepts three arguments. We called the function with the arguments. Run the script and you will see the output as shown below: 

Summarize  

That’s it. Let me summarize what we learned here:  

– ExtendScripts are like JavaScripts.

– ESTK provides an environment for developing, debugging, and running ExtendedScript.

, , ,