Scala5 Advanced ScalaScript Examples

The following examples show various things that can be done using advanced techniques in ScalaScript. Some of the examples and some may require features or fixes in the latest releases of Scala5.

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

Show Day and Date in Custom Language

Scala5 can display day and date the installed language, or using Windows system preferences. But if you need to display arbitrary languages for date and weekday, this example script shows a technique for using the SysTime() ScalaScript function to read the numeric value for the month or weekday, and thereby choose a custom text for the label. The example script produces French months and days but can be readily adapted for other languages.

The same technique could be employed if a script needs to use different date formats on-screen at once. (To use different date or time formats on different pages, you can just set the DateFormat or TimeFormat variables to the right value — see your Timing.sca config file for the current value.)

Click here for the Custom Language Day and Date.

Analog Clock

This example was supplied by Serge Verhoeven of C&W Commercials B.V., and shows an analog clock. Essentially it uses trigonometry functions to compute the shape of the clock hands and then draws them.

Click here for the Analog Clock example.

PDF Printing

Printing a PDF from an ICPlayer can be achieved as follows:

In Windows, every file extension (such as .PDF) has a default behavior, which usually is to open the viewer or editor for that file type. For a PDF file, this behavior normally opens Acrobat Reader or Acrobat. But you can modify the .PDF file extension to have a default behavior of silent printing. Then, a Scala script can use the Launch command to invoke the file using cmd /c mydocument.pdf and voila, it will print silently.

First, download the PDFPrintType.reg registry definition file that creates the following registry keys, which adds a file type called PDFPrint whose default action is to silently print:

REGEDIT4

[HKEY_CLASSES_ROOT\PDFPrint]
@="PDFPrint"

[HKEY_CLASSES_ROOT\PDFPrint\shell]
@="FilePrintSilentEx"

[HKEY_CLASSES_ROOT\PDFPrint\shell\FilePrintSilentEx]

[HKEY_CLASSES_ROOT\PDFPrint\shell\FilePrintSilentEx\ddeexec]
@="[FilePrintSilentEx(\"%1\")]"

[HKEY_CLASSES_ROOT\PDFPrint\shell\FilePrintSilentEx\ddeexec\Application]
@="acroview"

[HKEY_CLASSES_ROOT\PDFPrint\shell\FilePrintSilentEx\ddeexec\Topic]
@="control"

Now check your registry under HKEY_CLASSES_ROOT\.pdf. The default value will be something like "AcroExch.Document". Note that value down if you may wish to undo the following change and restore the normal PDF behavior! To associate the above PDFPrint behavior to the .PDF extension change the default value of HKEY_CLASSES_ROOT\.pdf to "PDFPrint". You can do that in RegEdit or using this PDFPrintActivate.reg registry definition file.

Now, in Scala script, use the Launch module to invoke your PDF file. For example:

Launch("cmd /c C:\temp\abc.pdf", Minimized(On));
The program cmd fires off a Windows command prompt. The /c parameter to cmd tells it to perform the specified command then exit. The command we specify is simply the document itself. The .pdf default behavior takes care of the rest.

Hotkey Module

Scala5 includes the Hotkey module that lets you trigger events for hotkeys. A Hotkey() atom in a group is active as long as the group is active, so you can make hotkeys work across pages. Use the same keynames and actions (Goto() or Use()) as are supported for button-hotkeys.

Click here for the Hotkey example.

Plasma Power On/Off

This example shows using the Serial module to operate the controls of a display device such as a plasma screen. The example controls a Toshiba TLP-B2 projector, but could be altered to control any other serial device for which serial interface documentation can be had.

Click here for the Power On/Off example.

Disable Escape Key

This example shows using EscapeKey script variable to disable the Escape key. More interestingly, it shows how you can still use a Hotkey() command so that Ctrl+F12 (or any key you choose) can briefly re-enable the Escape key.

This prevents accidental use of the Escape key while still maintaining a sequence that a maintainer/administrator can still use to quit playback.

Click here for the Disable Escape Key example.

World Clock / Variables and Formats

These ScalaScript examples show the implementation of a world clock using ScalaScript functions to manipulate strings, perform math, and do formatting, all on live variables.

The zip file contains two examples:

Click here for the World Clock example.

Crawl Style Changes

This script shows how to change the style of text during the middle of a crawl, using the style-change tags such as <outline="On">. Note that each of these tags must be at the beginning of the line within the crawl text stream.

Click here for the Crawl Styles example.