Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə90/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   86   87   88   89   90   91   92   93   ...   294
DelphiLanguageGuide

Static Arrays
Static array types are denoted by constructions of the form
array[
 indexType1, ..., indexTypen 
] of 
 baseType;
where each indexType is an ordinal type whose range does not exceed 2GB. Since the indexTypes index the array,
the number of elements an array can hold is limited by the product of the sizes of the indexTypes. In practice,
indexTypes are usually integer subranges.
In the simplest case of a one-dimensional array, there is only a single indexType. For example,
var MyArray: array [1..100] of Char;
declares a variable called 
MyArray
 that holds an array of 100 character values. Given this declaration, 
MyArray
[3]
 denotes the third character in 
MyArray
. If you create a static array but don't assign values to all its elements,
the unused elements are still allocated and contain random data; they are like uninitialized variables.
A multidimensional array is an array of arrays. For example,
type TMatrix = array[1..10] of array[1..50] of Real;
is equivalent to
type TMatrix = array[1..10, 1..50] of Real;
Whichever way 
TMatrix
 is declared, it represents an array of 500 real values. A variable 
MyMatrix
 of type
TMatrix
 can be indexed like this: 
MyMatrix[2,45];
 or like this: 
MyMatrix[2][45]
. Similarly,
77


packed array[Boolean, 1..10, TShoeSize] of Integer;
is equivalent to
packed array[Boolean] of packed array[1..10] of packed array[TShoeSize] of Integer;
The standard functions 
Low
 and 
High
 operate on array type identifiers and variables. They return the low and high
bounds of the array's first index type. The standard function 
Length
 returns the number of elements in the array's
first dimension.
A one-dimensional, packed, static array of Char values is called a packed string. Packed-string types are compatible
with string types and with other packed-string types that have the same number of elements. See Type compatibility
and identity.
An array type of the form 
array[0..x] of Char
 is called a zero-based character array. Zero-based character
arrays are used to store null-terminated strings and are compatible with PChar values. See Working with null-
terminated strings.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   86   87   88   89   90   91   92   93   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin