Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-01

Delphi mode syntax error

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Roland Turcan

Hello all,

I use Delphi style of programing in Lazarus to keep a compatibility with Kylix and therefore I want to get this code which is valid of Freepascal's ObjectPascal, but in {$MODE Delphi} it doesn't accept calling of "MyItems[index]" and writes "Array type required".

How to adapt this code to be valid for Delphi mode.

TYPE
  PtrUInt = DWord;
  TMyObj  = PtrUInt;
  PMyObj  = ^TMyObj;
  TArr    = ARRAY OF TMyObj;
procedure TForm1.FormCreate(Sender: TObject);
VAR MyItems         :PMyObj;
    Arr             :TArr;
begin
  SetLength (Arr, 5);
  Arr[0] := 1;
  Arr[1] := 2;
  Arr[2] := 3;
  Arr[3] := 4;
  Arr[4] := 5;
  MyItems := Pointer (Arr);
  ShowMessage (IntToStr (MyItems[0]));
end;

Thanks.

Reply by email

Alexander Klenin
to Roland Turcan
Roland Turcan wrote 17 lines
Hello all, I use Delphi style of programing in Lazarus to keep a compatibility with Kylix and therefore I want to get this code which is valid of Freepascal's ObjectPascal, but in {$MODE Delphi} it doesn't accept calling of "MyItems[index]" and writes "Array type required". How to adapt this code to be valid for Delphi mode. TYPE ?PtrUInt = DWord; ?TMyObj ?= PtrUInt; ?PMyObj ?= ^TMyObj; ?TArr ? ?= ARRAY OF TMyObj; procedure TForm1.FormCreate(Sender: TObject); VAR MyItems ? ? ? ? :PMyObj;

[skip]

?ShowMessage (IntToStr (MyItems[0])); end;

This should not compile, since pointer is not an array in Pascal. Delphi does not accept this code too.

Alexander S. Klenin

Reply by email