InfoChannel 3 VBScript and JScript Examples

The following examples show various things that can be done using VBScript or JScript in conjunction with ScalaScript. Some of the examples and some may require features or fixes in the latest releases of IC3.

These Scripts are technical examples for illustrative and educational purposes and are provided as-is. You are free to adapt, perfect, and use them in any network. As examples, they may not be 100% bullet-proof in your network. Should you require customized versions of these scripts to meet your needs, please contact your Scala Certified Partner or your Scala Channel Manager.

Table of Contents

Generate ScalaScript from XML Example (Added 2005-04-12)

This example shows a basic XML syntax for describing pages and elements, and shows how XSLT can be used to convert that XML into a ScalaScript. The resulting ScalaScript could for example be published using the Publish Server.

The XML grammar shown is only for illustrative purposes — in adapting this example you could develop a totally different schema. The syntax and capabilities of the XML grammar could be modified or extended by adding suitable logic to the XSLT file.

To convert an XML file called e.g. xmlscalascript.xml, into a ScalaScript called result.sca, do this:

cscript xml2scalascript.vbs xmlscalascript.xml result.sca

The example includes the XSL transform file, an sample XML source script, plus a simple VBScript that drives the XSL-transform.

Click here for the XML-to-ScalaScript Example.

ScalaScript Flow Control Example (Added 2005-03-09)

This example illustrates using VBScript to control the flow of a ScalaScript. The VBScript can request a goto, a return, or an exit, which the ScalaScript will perform. The VBScript also can send keystrokes to the ScalaScript.

Run this example with Designer running in a window on the desktop, so you can see and use the VBScript dialog box from which you control the example.

This example uses the GotoExpr() script command, which evaluates its string-parameter as a label, and jumps to the resulting page.

Click here for the ScalaScript Flow Control Example.

View RSS News Items in Scala (Updated 2006-04-05)

This VBScript reads an RSS feed and passes the contents back to Scala for display. Two different Scala scripts use the same VBScript:

The VBScript demonstrates a number of useful techniques:

Updated 2006-03-07:

Updated 2006-04-05:

This script has been tested against RSS 0.91, 1.0, and 2.0.

Adapting the VBScript to other XML grammars would typically be straightforward.

Click here for the RSS Reader Example.

Dynamically Load Text from the Web

This technique shows downloading a plain text file from a web site using VBScript, then passing that text through a variable to ScalaScript. The demo uses a couple of text files on scala.com but can easily be pointed elsewhere.

Click here for the Text from the Web Example.

This VBScript uses Microsoft HTTP Services (WinHTTP) for internet file transfers. These services are a standard part of Windows 2000 SP3 or newer, Windows XP SP1 or newer, or Windows Server 2003.

Dynamically Load Pictures from the Web

This technique shows downloading a JPEG from a web site using VBScript, then passing that JPEG correctly to Scala for playback. The demo uses a Times Square webcam.

Note: Actually using this script in a commercial application would require getting a license from the image provider. We make no claim whether the provider offers such a license, or whether use in a demo would even be permitted. This script is provided in order to showcase various important techniques.

Click here for the Pictures from the Web Example.

This VBScript uses Microsoft HTTP Services (WinHTTP) for internet file transfers. These services are a standard part of Windows 2000 SP3 or newer, Windows XP SP1 or newer, or Windows Server 2003.

Making Charts from Excel

This example talks to Excel, using a VBScript launched from Scala to fill a spreadsheet with some data and to generate a bar chart graphic which is then imported back into Scala for display. This example works best in IC3 Player -- IC3 Designer running full screen can get "switched out" by the Excel macro.

You'd need Excel on the player, which could be cost-prohibitive in some environments.

The data comes from a text-entry field in the Scala script, but the VBScript could obviously source the data from anywhere (text file, ODBC, serial port, whatever.)

Click here for the Excel Chart Example.

Database Integration Example

This example implements a library card catalog interface which can be searched by author, title, date of publication, etc.

The example uses Scala script to put up a screen where the user can select the type of search and enter a search term. Then it launches a VBScript to perform the appropriate SQL queries on a card catalog database, and returns the search results to Scala.

(The example opens the database as a file but can be trivially modified to use ODBC.)

Click here for the Card Catalog Database Example.

Use Special Scala Paths in VBScript

Scala supports standard Windows file system paths. In addition, Scala supports some "assignment" extensions, the most important of which is Content:, the Linked Content folder. For example, if you sent the file blah.txt using NetManager's Send Content job command, it would be found on the player using the Scala path Content:\blah.txt. Such paths cannot be used by Windows functions. Before you can use such paths, you must resolve the file name and lock the file.

By resolve we mean convert to a proper Windows path, e.g.:

C:\Documents and Settings\All Users\Documents\Scala\Content\blah.txt

By lock we mean ensure that the file doesn't change out from underneath you if a new version arrives while you're looking at it. The ScalaFileLock interface has LockScalaFile() and UnlockScalaFile() methods to manage that for you. LockScalaFile() returns a proper Windows path you can use, and ensures the file will not change out from underneath you. UnlockScalaFile() signals that you are done.

(Note that if a new version arrives while you are looking at a file in Linked Content, the new version is automatically queued for the next time you inquire, all without disturbing the current version.)

The example script shows the use of these techniques. You'll need to place a simple text file in your Linked Content folder, either by dragging into the appropriate folder or by sending it with Send Content from NetManager.

Click here for the Scala Paths Example.

Feeding a crawl from Windows Script

This example illustrates how to feed a text crawl from a VBScript program. In this example, the data is canned weather information. In a real-world application, the VBScript would have to obtain the textual information by:

The current example does not dwell on the data acquisition problem, but rather Shows the capabilities and usage of the text crawl interface.

Click here for the Windows Script Crawl Example.


Scala exclamation mark logo