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ə121/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   117   118   119   120   121   122   123   124   ...   294
DelphiLanguageGuide

Resource Strings
Resource strings are stored as resources and linked into the executable or library so that they can be modified
without recompiling the program.
Resource strings are declared like other true constants, except that the word const is replaced by resourcestring.
The expression to the right of the = symbol must be a constant expression and must return a string value. For
example,
105


resourcestring
  CreateError = 'Cannot create file %s'; 
  OpenError = 'Cannot open file %s';  
  LineTooLong = 'Line too long';
  ProductName = 'Borland Rocks';
  SomeResourceString = SomeTrueConstant;
Typed Constants
Typed constants, unlike true constants, can hold values of array, record, procedural, and pointer types. Typed
constants cannot occur in constant expressions.
Declare a typed constant like this:
const identifier: type = value
where identifier is any valid identifier, type is any type except files and variants, and value is an expression of type
type. For example,
const Max: Integer = 100;
In most cases, value must be a constant expression; but if type is an array, record, procedural, or pointer type, special
rules apply.
Array Constants
To declare an array constant, enclose the values of the array's elements, separated by commas, in parentheses at
the end of the declaration. These values must be represented by constant expressions. For example,
const Digits: array[0..9] of Char = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); 
declares a typed constant called 
Digits
 that holds an array of characters.
Zero-based character arrays often represent null-terminated strings, and for this reason string constants can be used
to initialize character arrays. So the previous declaration can be more conveniently represented as
const Digits: array[0..9] of Char = '0123456789';
To define a multidimensional array constant, enclose the values of each dimension in a separate set of parentheses,
separated by commas. For example,
type TCube = array[0..1, 0..1, 0..1] of Integer;
const Maze: TCube = (((0, 1), (2, 3)), ((4, 5), (6,7)));
creates an array called 
Maze
 where
Maze[0,0,0] = 0
Maze[0,0,1] = 1
Maze[0,1,0] = 2
Maze[0,1,1] = 3
Maze[1,0,0] = 4
Maze[1,0,1] = 5
106


Maze[1,1,0] = 6
Maze[1,1,1] = 7
Array constants cannot contain file-type values at any level.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   117   118   119   120   121   122   123   124   ...   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