[fpc-pascal] fpc has trouble with array types
    Felipe Monteiro de Carvalho 
    felipemonteiro.carvalho at gmail.com
       
    Tue Oct 18 09:09:54 CEST 2011
    
    
  
On Tue, Oct 18, 2011 at 5:47 AM, Andrew Pennebaker
<andrew.pennebaker at gmail.com> wrote:
> function XlatPrime () : array of byte;
> begin
> XlatPrime := (
> $64, $73, $66, $64, $3b, $6b, $66, $6f,
I think that a syntax similar to this is available only for constant
initialization. Actually I remember it from constant initialization
for records. Maybe it works for arrays too.
The usual way to set a dynamic array is:
function XlatPrime () : array of byte;
begin
  SetLength(XlatPrime, 20);
  XlatPrime[0] := $64;
  XlatPrime[1] := $73;
  etc
But you can also try this (maybe it works):
function XlatPrime () : array of byte;
const ConstXlatPrime: array[0..19] of Byte = (
 $64, $73, $66, $64, $3b, $6b, $66, $6f,....);
begin
  Result := ConstXlatPrime;
end;
-- 
Felipe Monteiro de Carvalho
    
    
More information about the fpc-pascal
mailing list