Hi!
I am currently learning Lazarus / Free Pascal (I am familiar with other programming languages), and I ran into the following problem.
This code:
var
TestFileName: string;
begin
for TestFileName in ['abc', 'defghi'] do
WriteLn(TestFileName);
produces this output:
You see, the second string is truncated, it should be defghi.
Now I wonder ...
Is this a bug?
Is it a feature?
Is there an explanation for this behavior?
How do I write string array literals that work?
Thanks for your help.
Regards,
jflipp
it is what you call a bug!
It's already known about.
The problem is it takes the length of the first element as the length for the remaining elements.
Now, you need to ask your self "Do you feel lucky?", that is, lucky if it gets fixed..
Personally I've never had a need for an inline const string like that and I need to check Delphi because I am not even sure if it's supported there.
Make a Const MyLits :array of string =('....','...') etc
something like that.
EDIT
Const
MyList : Array[ 0..1 ] of string = ('one','Three'); etc