Still find in bearings with Delphi 11

interface
Uses
     Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
     System.Classes;


Var
   Stream: TMemoryStream;
   aFile: TFileStream;
   bFile: TFileStream;

implementation



end.

initialization
Begin
 Stream := TMemoryStream.Create;
 aFile: TFileStream.Create(?);
 bFile: TFileStream.Create;
end;

finalization
Begin
 Stream.free;
 aFile.Free;
 bFile.Free;
end;

I wrote the above code and the IDE
1/ does not support the creation of the create instruction
2/ TMemoryStream and TFileStream are still supported in System.Classes - correct
4/ what am I doing wrong

TFileStream has a constructor that requires the filename and the openmode. See

http://docwiki.embarcadero.com/Libraries/Athens/en/System.Classes.TFileStream.Create

The

end.

should be at the end of the file as well, not above the initialization and finalization sections.

Hi @lexdeanair - my following comment might come across as condescending or rude; if that’s the case please know that’s not my intention, ok? I am trying to be helpful.

It does seem like you’re making a few basic errors in your code which might be avoided with some reading about the fundamentals of the Object Pascal language first.

Can I suggest you get Marco Cantú’s Object Pascal handbook and take a quick read of it first? It covers things like where the end. should or shouldn’t be along with some other things like looking up help for a particular class constructor (I realize the Delphi help is currently suboptimal but we’re working to improve it).

To get the book go here: Free Object Pascal Handbook by Marco Cantu - Embarcadero

You will have to register but it will send you the book completely free with no catches.

I am really glad you’re teaching yourself Delphi. Stick at it - we’re all here to help.

Ian.

1 Like

I was spending hours wasted over a wrong end statement after you pointing it out
Delphi was not explaining the error
thanks

It would have been giving a compiler hint or warning that there was non-compiling code after the end statement.

1 Like