Jump to content
Lars Fosdal

Replace default code template?

Recommended Posts

Whenever I write console test app, I am annoyed that I must change from

 

program Project2;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

begin
  try
    { TODO -oUser -cConsole Main : Insert code here }
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

to

program Project2;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils;

begin
  try
    try

    except
      on E: Exception do
        Writeln(E.ClassName, ': ', E.Message);
    end;
  finally
  {$ifdef Debug}
    Write('Press Enter: ');
    Readln;
  {$endif}
  end;
end.

which is what I normally want.


Is there a way to replace the default code template for a new console project?

I would have expected to find it under Tools | Template Libraries - but there is no console project there.
 

Share this post


Link to post

Alternative could be Ctrl-A, Delete, "cons", Space + predefined code template named "cons" with the contents you want.

Edited by Fr0sT.Brutal
  • Like 1

Share this post


Link to post

Why not simply use one of the oldest features of Delphi, The Object Repository?  Not only can you store a pre-designed Form Template for reuse but you can create an application and store the whole application as a Project Template.

 

In your case, the project would simply be a single-file .DPR.

 

Here's an old YouTube Video that explains how to use the Object Repository--the latter half demonstrates project templates.

  • Like 3

Share this post


Link to post
16 hours ago, corneliusdavid said:

Why not simply use one of the oldest features of Delphi, The Object Repository?

AFAIR they disappeared every time I installed an update, I don't know, could have been a one-time issue.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×