beautypg.com

Arrays, Using and naming arrays – Visara Master Console Center Scripting Guide User Manual

Page 38

background image

Chapter 3 Script Syntax

Scripting Guide

38

Arrays

Using and Naming Arrays

ƒ

There are two types of arrays, integer arrays and string arrays.
Integer arrays are prefixed with a %. String arrays are prefixed by a
$.

ƒ

The maximum number of elements per array is limited only by
available memory. Array elements are dynamically allocated—no size
declaration, no limits, no reallocation needed.

ƒ

The syntax for arrays is:

ArrayName[ ArrayIndex].

ƒ

Array elements are accessed by surrounding the array index with
square brackets “[ ]”.

ƒ

Arrays are indexed by a numeric expression (normal array) or a
character expression (associative array). The only limitation to index
expressions is that the index cannot be the direct return value of a
script. For example, the following statement:

$Var := $Array[ Script()]

must be written as

%Index := Script()

$Var := $Array[ %Index]

to make clear what is the index type (array type). This assumes
Script() returns a numeric value and $Array is a normal array.

ƒ

An array’s indexing type (normal or associative) is determined by the
first use of the array encountered by the compiler (processed from
script beginning to end).

ƒ

Arrays can be copied to new arrays just like any other variable, if the
destination array is new or of the same structure as the source:

$A[1] := “Hello”

$A[2] := “World”

$B := $A

// $B[1] will contain “Hello” and

// $B[2] will contain “World”