Hi
Hi,
I have a custom string type called TMyString. And i have an array of TMyString :
type
TMyString = AnsiString;
const
MyItem1 : TMyString = 'yyy';
MyItem2 : TMyString = 'xxx';
MyItem3 : TMyString = 'zzz';
MyArray:array[0..2]of TMyString = (//
MyItem1,
MyItem2,
MyItem3);
Every time ,i try to run my code ,i got :"E2026 Constant expression expected" error.
Items (MyItemX) need to be declared as constant , so when changing ,MyArray will get updated.
Is there any way to make the code run without converting Items to quoted string in MyArray ?.
I have a custom string type called TMyString. And i have an array of TMyString :
type
TMyString = AnsiString;
const
MyItem1 : TMyString = 'yyy';
MyItem2 : TMyString = 'xxx';
MyItem3 : TMyString = 'zzz';
MyArray:array[0..2]of TMyString = (//
MyItem1,
MyItem2,
MyItem3);
Every time ,i try to run my code ,i got :"E2026 Constant expression expected" error.
Items (MyItemX) need to be declared as constant , so when changing ,MyArray will get updated.
Is there any way to make the code run without converting Items to quoted string in MyArray ?.
Because they are typed const not const. See http://stackoverflow.com/questions/2714365/delphi-all-constants-are-constant-but-some-are-more-constant-than-others
ReplyDeleteDoes
ReplyDeleteconst
MyItem1 = TMyString('yyy');
solve the problem?
Lars Fosdal Yes it solve my problem.
ReplyDeleteThanks