> This SHOULD NOT work in BP or any flavor of Pascal, any more than the
> following should work:
>
> const Digit: array[0..255] of 0..9 = 123456789101112;
>
> A string is a different data type than an array of char, with a lot of
> different methods.
>
> I am surprised tht BP identifies short arrays of char with short strings.
>
> Would (and should) this work?
>
> program foo;
>
> var ch1, ch2, ch3: array[1..100] of char;
>
> begin
> ch1 := '123';
> ch2 := '456';
> ch3 := ch1+ch2; (* or ch3 := Concat(ch1, ch2); *)
>Writeln(ch3, ' ', Length(ch3));
> end.
>
> I say absolutely not. HF
I tried this, and it does not compile. The Borland compiler will not allow
ch1 := '123';
Assigning a string value to a character array is a shortcut for initializing character arrays so that you don't have to write
Const ch: array[1..100] of char = ('H', 'e', 'l', 'l', 'o');
Instead you can write
Const ch: array[1..100] of char = 'Hello';
However this works only in Const clauses, and only when the size of the array elements is less than 256 characters.
If you need to initialize a character array greater than 255 chars in BP, you can resort to using absolute. For example
Const ch1: array[1..5,1..100] of char
= ('First 100 chars', 'Second 100 chars', ..., 'Last 100 chars');
Var ch: array[1..500] of char
absolute ch1;
Frank Rubin