Jump to content
wuwuxin

Delphi code formatter inquiry

Recommended Posts

Any third-party code formatter that can correctly format the inline var?

Share this post


Link to post

cnpack formater is probably the best one out there, I'm using it daily to format code containing inlines without any problem.

Share this post


Link to post
On 4/10/2022 at 2:00 AM, wuwuxin said:

Any third-party code formatter that can correctly format the inline var?

The one in GExperts apparently can do that. I didn't really know but just tested it with:

procedure bla;
begin
  for var i: Integer := 0 to List.Count - 1 do begin

  end;
  for var i := 0 to List.Count - 1 do begin

  end;
  var blub: Integer = 5;
  Inc(blub);

  var X := 0.5;
  var Y := X - 3;
end;

And this looks fine to me.

Share this post


Link to post
4 hours ago, dummzeuch said:

The one in GExperts apparently can do that. I didn't really know but just tested it with:


procedure bla;
begin
  for var i: Integer := 0 to List.Count - 1 do begin

  end;
  for var i := 0 to List.Count - 1 do begin

  end;
  var blub: Integer = 5;
  Inc(blub);

  var X := 0.5;
  var Y := X - 3;
end;

And this looks fine to me.

With the default code formatter, it goes 'wrong' when you skip the type:

 

var
  settings := dtmSettings.ReadRecord;

 

Or....
 

var settings : TSettings := dtmSettings.ReadRecord;

 

Share this post


Link to post
23 minutes ago, emileverh said:

With the default code formatter, it goes 'wrong' when you skip the type:

 

var
  settings := dtmSettings.ReadRecord;

 

Or....
 

var settings : TSettings := dtmSettings.ReadRecord;

I'm not sure what you're trying to tell me. I had such an example in my test:

 var X := 0.5;

and it seems to work. This was with the "twm" settings because that's what I use. I haven't tried any of the others.

Share this post


Link to post
3 hours ago, dummzeuch said:

I'm not sure what you're trying to tell me. I had such an example in my test:


 var X := 0.5;

and it seems to work. This was with the "twm" settings because that's what I use. I haven't tried any of the others.

May be I am too quick with my answer. .. sorry! The default built in ( IDE ) source code formatter does it wrong. I did not try the GEXPERTS formatter ( until now )

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

×