BrightSign BrightScript 3.0 Reference Guide

BRIGHTSCRIPT REFERENCE
Compatible with firmware versions 3.8.x and later
MANUAL
BrightScript version 3.0
BrightSign, LLC. 16780 Lark Ave., Suite B Los Gatos, CA 95032 | 408-852-9263 | www.brightsign.biz
TABLE OF CONTENTS
BrightScript Characteristics ............................................................................................................................................... 1
BrightScript Operation ....................................................................................................................................................... 1
Identifiers ........................................................................................................................................................................... 3
Types ................................................................................................................................................................................. 3
Type Declaration Characters ............................................................................................................................................. 6
Literals (Constants) ........................................................................................................................................................... 6
Array Literals ..................................................................................................................................................................... 7
Assoiative Array Literals .................................................................................................................................................... 7
Invalid Object Return ......................................................................................................................................................... 8
Dynamic Typing for Numbers ............................................................................................................................................ 8
Number Type Conversion .................................................................................................................................................. 8
Type Conversion and Accuracy ......................................................................................................................................... 9
Logical and Bitwise Operators ......................................................................................................................................... 10
Dot Operator .................................................................................................................................................................... 11
Array and Function-Call Operators .................................................................................................................................. 12
Equals Operator .............................................................................................................................................................. 13
BrightScript Objects ......................................................................................................................................................... 15
Wrapper Objects .............................................................................................................................................................. 15
Interfaces ......................................................................................................................................................................... 17
Statement and Interface Integration ................................................................................................................................ 17
XML Support in BrightScript ............................................................................................................................................ 18
LIBRARY ......................................................................................................................................................................... 31
DIM .................................................................................................................................................................................. 32
Assignment (“=”) .............................................................................................................................................................. 33
END ................................................................................................................................................................................. 34
STOP ............................................................................................................................................................................... 34
GOTO .............................................................................................................................................................................. 34
RETURN .......................................................................................................................................................................... 35
REM................................................................................................................................................................................. 35
PRINT .............................................................................................................................................................................. 35
FOR / END FOR .............................................................................................................................................................. 38
FOR EACH IN / END FOR .............................................................................................................................................. 39
WHILE / EXIT WHILE ...................................................................................................................................................... 40
IF / THEN / ELSE ............................................................................................................................................................ 40
Block IF / ELSEIF / THEN / ENDIF .................................................................................................................................. 41
Function() As Type / End Function .................................................................................................................................. 43
Type() .............................................................................................................................................................................. 48
GetGlobalAA() ................................................................................................................................................................. 48
Rnd()................................................................................................................................................................................ 48
Box() ................................................................................................................................................................................ 49
Run()................................................................................................................................................................................ 49
Eval() ............................................................................................................................................................................... 51
GetLastRunCompileError() .............................................................................................................................................. 51
GetLastRunRuntimeError() .............................................................................................................................................. 52
Console Commands ........................................................................................................................................................ 54
1
INTRODUCTION
BrightScript is a powerful scripting language for building media and networked applications for embedded devices. This language features integrated support for a lightweight library of BrightScript objects, which are used to expose the API of the platform (device) that is running BrightScript. The BrightScript language connects generalized script functionality with underlying components for networking, media playback, UI screens, and interactive interfaces; BrightScript is optimized for generating user-friendly applications with minimal programmer effort.
This reference manual specifies the syntax of BrightScript. For a detailed listing of BrightScript objects, refer to the
BrightScript Object Reference Manual. This manual is intended as a reference for those who
have some level of programming experience—it is not a tutorial for those who are new to programming.
For a quick flavor of BrightScript code, see
Appendix C for a game of "snake" created using BrightScript.
BrightScript Characteristics
The following are some general characteristics of BrightScript, as compared to other common scripting languages:
BrightScript is not case sensitive.
Statement syntax is similar to Python, Basic, Ruby, and Lua (and dissimilar to C).
Like JavaScript and Lua, objects and named data-entry structures are associative arrays.
BrightScript supports dynamic typing (like JavaScript) and declared types (like C and Java).
Similar to .Net and Java, BrightScript uses "interfaces" and "components" (i.e. objects).
BrightScript Operation
BrightScript code is compiled into bytecode that is run by an interpreter. The compilation step occurs every time a script is loaded and run. Similar to JavaScript, there is no separate compilation step that results in a saved binary file.
Loading...