Teledyne-lecroy SAS_SATA Protocol Suite Verification Script Engine Bedienungsanleitung Seite 32

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 97
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 31
32
Chapter 8: Declarations
8.1 Array Declarations
Scripts can declare an array object.
Format: Array( source, size, default_value )
Parameters
source (optional) List (collection or stand-alone value) of values to fill array.
size (optional) Size of array
default_value (optional) Default value to fill array, if size is greater than size of source.
Examples
set MyArray = Array( [1, 2, 3] );
# Creates an array of 3 elements from list : [1,2,3].
set MyArray = Array( [1, 2, 3, 4, 5, 6] );
# Creates an array of 6 elements from list : [1,2,3,4,5,6 ].
set MyArray = Array( [1, 2, 3, 4, 5, 6], 20, 23 );
# Creates an array of 20 elements. Fills first 6 elements from
# list : [1,2,3,4,5,6 ]. Aftewards, fills remainder with 23.
set MyArray = Array( 64 );
# Creates an array of one element [64].
set MyArray = Array();
# Creates an empty array.
Remarks
Arrays can be iterated using the same syntax as lists (but more efficiently):
for( i = 0; i < sizeof(MyArray); i++ )
{
ReportText( FormatEx( "MyArray[%d] = %d", i, MyArray[ i ] ) );
}
Arrays can use the operators sizeof(), first(), more(), next(), prev(), and last().
Therefore, the example array code above can be written:
i = 0;
for( item = first(MyArray); more(MyArray); item = next(MyArray) )
{
ReportText( FormatEx( "MyArray[%d] = %d", i, item ) );
i++;
}
Seitenansicht 31
1 2 ... 27 28 29 30 31 32 33 34 35 36 37 ... 96 97

Kommentare zu diesen Handbüchern

Keine Kommentare