User manual

3
CHAPTER 2
CATC Scripting Language for USB Values
CHAPTER 2: VALUES
There are five value types that may be manipulated by a script: integers, strings,
lists, raw bytes,andnull. CSL is not a strongly typed language. Value types need
not be pre-declared. Literals, variables and constants can take on any of the five
value types, and the types can be reassigned dynamically.
Literals
Literals are data that remain unchanged when the program is compiled. Literals are
a way of expressing hard-coded data in a script.
Integers
Integer literals represent numeric values with no fractions or decimal points. Hexa-
decimal, octal, decimal, and binary notation are supported:
Hexadecimal numbers must be preceded by 0x: 0x2A, 0x54, 0xFFFFFF01
Octal numbers must begin with 0: 0775, 017, 0400
Decimal numbers are written as usual: 24, 1256, 2
Binary numbers are denoted with 0b: 0b01101100, 0b01, 0b100000
Strings
String literals are used to represent text. A string consists of zero or more characters
and can include numbers, letters, spaces, and punctuation. An empty string ("")
contains no characters and evaluates to false in an expression, whereas a non-empty
string evaluates to true. Double quotes surround a string, and some standard
backslash (\) escape sequences are supported.
String Represented text
"Quote: \"This is a string
literal.\""
Quote: "This is a string
literal."
"256"
256
**Note that this does not represent the integer
256, but only the characters that make up the number.
"abcd!$%&*" abcd!$%&*
"June 26, 2001" June 26, 2001
"[ 1, 2, 3 ]" [ 1, 2, 3 ]
Table 2.1: Examples of String Literals