2 map declaration, Eclaration – Teledyne LeCroy SAS_SATA Protocol Suite Verification Script Engine Reference Manual User Manual

Page 33

Advertising
background image


33

Arrays can grow and change dynamically through the functions: InsertAt, RemoveAt, and
SetAt:

set MyArray = Array( [1, 2, 3, 4, 5, 6] );

InsertAt ( MyArray, 0, 0 );

# [0, 1, 2, 3, 4, 5, 6]

RemoveAt( MyArray, 0 );

# [1, 2, 3, 4, 5, 6]

SetAt( MyArray, 8, 8);

# [1, 2, 3, 4, 5, 6, null, 8]

# Use operators + and +=.

set MyArray = Array( [1, 2, 3, 4, 5, 6] );
MyArray += [7, 8];

# [1, 2, 3, 4, 5, 6, 7, 8]

8.2 Map Declaration

Scripts can declare a map object.


Format
:

Map( source, hash_size )



Parameters

source

(optional) List (collection or stand-alone value) of values to fill map.
The source paremeter (if present) MUST be a list of sublists, where the
first item of the sublist MUST be either an integer or string and
becomes a 'key', whereas the sublist itself becomes a 'value'.

hash_size

(optional) Hash size of map (default = 29)


Example 1

set WiNetFrameTable =
Map(
[
#--------------------------------------------------------------------
# Type , Type Name, Full Type name, Color, Decoder function|
#--------------------------------------------------------------------
[0xFFFF, null, null , null, null ],
[0, "DATA", "Standard Data", WN_DATA_COLOR, "ShowWNDataFrame" ],
[1, "ABBR DATA", "Abbreviated Data", WN_ABBR_DATA_COLOR,
"ShowWNAbbrDataFrame" ],
[2, "CONTROL", "Control Frame", WN_CONTROL_COLOR, "ShowCtrlFrame"],
[3, "ASSOC", "Association Frame", WN_ASSOC_COLOR, "ShowAssocFrame"]
]
);

The above example creates a map ( hash-table ) with the following key/value pairs:
key : Value:
0xFFFF : [0xFFFF, null, null ,null, null ]
0 : [0, "DATA", "Standard Data", WN_DATA_COLOR,"ShowWNDataFrame"]
1 : [1, "ABBR DATA", "Abbreviated Data", WN_ABBR_DATA_COLOR,
"ShowWNAbbrDataFrame" ]
2 : [2, "CONTROL", "Control Frame", WN_CONTROL_COLOR,
"ShowCtrlFrame"]
3 : [3, "ASSOC", "Association Frame", WN_ASSOC_COLOR,
"ShowAssocFrame"]
This syntax can transform lists used like maps into map objects in existing scripts.

Advertising