BrightSign BrightScript 2 Reference Guide User Manual

Page 8

Advertising
background image

8

Dynamic typing – Unless otherwise specified, a variable is dynamically typed.

This means that the type is determined by the value assigned to it at evaluation
time. For example “1” is an int, “2.3” is a float, “hello” is a string, etc. A
variable that does not end in a type specifier character is dynamically typed. It
will take on the type of the expression assigned to it, and may change its type.
For example: a=4 creates a as integer, then a = “hello”, changes the variable a to
a string.



Here are some examples of types. ? is a short cut for the “print” statement. The “type()”
function returns a string that identifies the type of the expression passed in.

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

BrightScript> ?type(1)
Integer

BrightScript> ?type(1.0)
Float

BrightScript> ?type("hello")
String

BrightScript> ?type(CreateObject("roList"))
roList

BrightScript> ?type(1%)
Integer

BrightScript> b!=1
BrightScript> ?type(b!)
Float

BrightScript> c$="hello"
BrightScript> ?type(c$)
String

BrightScript> d="hello again"
BrightScript> ?type(d)
String

BrightScript> d=1
BrightScript> ?type(d)
Integer

BrightScript> d=1.0
BrightScript> ?type(d)
Float

Literals (Constants)

Type Boolean: true, false

Advertising