Technical notes on using Analog Devices DSPs, processors and development tools
Contact our technical support at dsp.support@analog.com and at dsptools.support@analog.com
Or vi sit our o n-li ne r esou rces htt p:/ /www.analog.com/ee-notes and http://www.analog.com/processors
An Introduction to Scripting in VisualDSP++®
Contributed by Jason Pound Rev 1 – May 11, 2004
Introduction
VisualDSP++® 3.5 introduces a language-independent scripting host that utilizes the Microsoft®
ActiveX® script host framework. The scripting host permits the use of multiple scripting engines
(languages) that conform to the Microsoft ActiveX script engine framework. Scripting is a powerful and
flexible tool that you can use to extend and customize the built-in capabilities of the IDDE or to automate
repetitive tasks. It is ideal for non-interactive scripting needs such as accessing DSP resources
(reading/writing memory or reading/writing registers), performing repetitive tasks (executing external
tools prior to or after a build completes, or setting registers and memory prior to loading a program), or
running full-blown regression tests. These are only a few examples of what can be done with scripting; the
possibilities are endless. This EE-Note outlines the components involved in scripting and explains how to
use the new scripting capabilities in the IDDE.
A Note About Tcl
Prior to the release of VisualDSP++ 3.5, Tcl (http://www.tcl.tk) was the default scripting language in the
IDDE. Since Tcl is not a true ActiveX script engine, Tcl has been deprecated with release 3.5 and will not
be covered in this EE-Note. Although most Tcl functionality has been maintained for backward
compatibility, no new functionality will be added to the Tcl library going forward.
Supported Languages
The following script languages are officially supported by Analog Devices:
VBScript
A scripting language developed by Microsoft, with syntax based on Visual Basic®. If you already know
Visual Basic or Visual Basic for Applications (VBA), VBScript will be very familiar.
JScript
A scripting language developed by Microsoft that implements the ECMAScript standard. It is a very
powerful interpreted scripting language that is object-based and loosely typed. This will be the most
familiar language to users that are comfortable with C/C++.
Copyright 2004, Analog Devices, Inc. All rights reserved. Analog Devices assumes no responsibility for customer product design or the use or application of
customers’ products or for any infringements of patents or rights of others which may result from Analog Devices assistance. All trademarks and logos are property
of their respective holders. Information furnished by Analog Devices applications and development tools engineers is believed to be accurate and reliable, however
no responsibility is assumed by Analog Devices regarding technical accuracy and topicality of the content provided in Analog Devices’ Engineer-to-Engineer Notes.
Although each scripting language has its own syntax, all the scripting languages access the same features
in VisualDSP++. For example, calls to subroutines (methods with no return types) using VBScript do not
use parentheses, even though JScript does.
Although the IDDE permits the use of other scripting languages, Analog Devices Technical
!
The benefits of using the new ActiveX script engines include:
• More language choices
• Better language support and documentation
• Shorter learning curve for users who are already familiar with a language
• Much more powerful API (Automation)
• Better performance and flexibility
Support does not support them at this time.
a
VisualDSP++ Automation API
VisualDSP++ includes a unified programming interface, called the VisualDSP++ Automation API, which
provides all script languages with broad access to all of the capabilities of the IDDE in a languageindependent manner. Automation, formerly called OLE Automation, is a Microsoft COM-based
technology that allows an application to use the services provided by another application (VisualDSP++).
It makes the VisualDSP++ environment programmable by any application that understands Automation.
Since script languages (VBScript or JScript) support the COM interface, they may be used to access to the
Automation API.
When a language is selected as the current language in the Console tab of the IDDE’s Output window, an
instance of the VisualDSP++ application object is created. This object, called
the VisualDSP++ Automation’s methods and properties. The use of this object is shown later in this
document. For detailed information about the Automation API, refer to the online Help, which can be
found at
<VisualDSP install>\help\VisualDSPAutomation.chm.
Idde, is used to easily access
Detecting Installed Languages
By default, under Windows 2000 or later, everything you need for scripting is already installed on the
operating system. However, under Windows 98 and Windows NT, if VisualDSP++ does not automatically
detect any languages, you may have to download
of Internet Explorer, which installs the VBScript and JScript libraries necessary to use the scripting
capabilities. For further information, visit the following Microsoft site:
Microsoft Windows Script 5.6 or upgrade to the latest version
http://www.microsoft.com/scripting
An Introduction to Scripting in VisualDSP++® (EE-235) Page 2 of 18
a
Getting Familiar with Scripting
Open VisualDSP++ and click the Console tab of the Output window. To see the list of available
languages, right-click in the Output window and choose
current scripting language.
Figure 1. Language selection menu
The best way to become familiar with the scripting capabilities is to enter a few commands in the Output
window. Type the following lines:
Languages. Choose VBScript to select it as the
a = 5
b = 2
c = a + b
? c
Listing 1. Simple commands
Evaluate expressions by preceding the text with a question mark (?) when a Microsoft activeX
!
Now, let’s use the Idde object mentioned earlier to access some automation methods and properties. Type
the following commands in the Output window and observe the output for each command:
An Introduction to Scripting in VisualDSP++® (EE-235) Page 3 of 18
Figure 2. Output window with Idde object commands
Loading a Script
VisualDSP++ provides multiple ways to load a script:
a
• Choose File->Load Script from the IDDE’s main menu
• Choose File->Recent Scripts from the IDDE’s main menu
• Choose Load Script from the Output window’s right-click menu
• Choose Load Script via the right-click menu in an editor window
Following is an example. First, right-click in the Output window, and change the script language to
Open a new document in VisualDSP++ by clicking
into the blank document. Save the file as
been saved, right-click on the
window, type
PrintSessionList() and press Enter. The list of sessions previously created in VisualDSP++
LoadScriptEx.js file in the editor window and choose LoadScript. In the Output
LoadScriptEx.js to a directory of your choice. Once the file has
File->New on the main menu. Copy the following script
An Introduction to Scripting in VisualDSP++® (EE-235) Page 4 of 18
Figure 3. Output window with PrintSessionList output
Code not contained within a function is considered global code and executes immediately after the
!
script is loaded. Code contained within a function is executed only when called within the global
code or when you type the function name into the Output window of the IDDE.
a
Automatically Invoking a Script
A script can automatically be loaded on startup of the IDDE by using the –f parameter and a shortcut to
the
Idde.exe. This is ideal for recurring tasks.
To use this feature, create a shortcut to the
“–f” and file name at the end of the Target field located on the Shortcut tab (Figure 4). Click OK. The next
time the IDDE is started, the script will load automatically.
Idde.exe. Right-click on the shortcut and choose Properties. Place
Figure 4. Specifying a script from the Shortcut tab
An Introduction to Scripting in VisualDSP++® (EE-235) Page 5 of 18
a
Creating a Toolbar Button
You can map a script to a toolbar button in the IDDE. For example, let’s use the PrintSessionList code
from Listing 3 to create a toolbar button. First, create a tool by choosing
the
Tools tab. Then click New to define the tool.
Settings->Preferences and clicking
Figure 5. Tools tab of the Preferences dialog box
As shown in Figure 6, assign the new tool with the name Print Available Sessions and specify the function to
be executed, PrintSessionList(). Enter the directory where the script is located and select the Script command
option. Click
An Introduction to Scripting in VisualDSP++® (EE-235) Page 6 of 18
OK to save the tool’s settings.
Loading...
+ 12 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.