beautypg.com

Teledyne LeCroy CATC Scripting Language Reference Manual User Manual

Page 15

background image

C

HAPTER

4

Operators

CATC Scripting Language

11


Operator
Symbol

Description

Operand
Types

Result
Types

Examples

Index Operator

[ ]

Index or
subscript

Raw Bytes

Integer

Raw = '001122'

Raw[1] = 0x11

List

Any

List = [0, 1, 2, 3, [4, 5]]

List[2] = 2

List[4] = [4, 5]

List[4][1] = 5
*Note: if an indexed Raw value is assigned to any
value that is not a byte ( > 255 or not an integer), the
variable will be promoted to a list before the
assignment is performed.

Associative Operator

( )

Associative

Any

Any

( 2 + 4 ) * 3 = 18

2 + ( 4 * 3 ) = 14

Arithmetic Operators

*

Multiplication

Integer-integer

Integer

3 * 1 = 3

/

Division

Integer-integer

Integer

3 / 1 = 3

%

Modulus

Integer-integer

Integer

3 % 1 = 0

+

Addition

Integer-integer

Integer

2 + 2 = 4

String-string

String

"one " + "two" = "one two"

Raw byte-raw byte

Raw

'001122' + '334455' =

'001122334455'

List-list

List

[1, 2] + [3, 4] = [1, 2, 3, 4]

Integer-list

List

1 + [2, 3] = [1, 2, 3]

Integer-string

String

"number = " + 2 = "number = 2"
*Note: integer-string concatenation uses decimal
conversion.

String-list

List

"one" + ["two"] = ["one", "two"]

-

Subtraction

Integer-integer

Integer

3 – 1 = 2

Increment and Decrement Operators

++

Increment

Integer

Integer

a = 1

++a = 2

b = 1
b++ = 1
*Note that the value of b after execution is 2.

--

Decrement

Integer

Integer

a = 2

--a = 1

b = 2

b-- = 2
*Note that the value of b after execution is 1.

Table 4.2: Operators