emileverh 22 Posted March 1, 2022 Hi! For D11; Can anybody tell me what setting(s) I needin Tools-Options-Language-Formatter ( or may be it's not possible at all ) the format an inline var. I want to have the keyword in front of the variable, now a line break is added. By the way the line break is not added in a 'regular' declaration This is what I want: TfrmMain.SomeStuff; var x : integer; begin ... lots of code var settings := dtmSettings.ReadRecord; end; And Delphi 11 does this: TfrmMain.SomeStuff; var x : integer; begin ... lots of code var settings := dtmSettings.ReadRecord; end; Any help is welcome 😉 1 Share this post Link to post
timfrost 79 Posted March 1, 2022 The GExperts formatter seems to do what you ask, here. I have never used the one that comes in the IDE, though. Share this post Link to post
Stano 143 Posted March 1, 2022 (edited) That is not possible. Download the book by Bent Normann Olsen (docx). Page 71. See above Edited March 1, 2022 by Stano Share this post Link to post
Attila Kovacs 631 Posted March 1, 2022 54 minutes ago, Stano said: That is not possible. Download the book by Bent Normann Olsen (docx). Page 71. It's hard to find that reference after you made 100 new editions without any official source. Share this post Link to post
Stano 143 Posted March 1, 2022 It is true. But there weren't 100 of them I don't know exactly what you mean by "official source". The original no longer exists. Totally down. https://en.delphipraxis.net/topic/6357-a-book-about-object-pascal-style-guide/?page=3 Share this post Link to post
Uwe Raabe 2064 Posted March 1, 2022 The original PDF can be found here: https://en.delphipraxis.net/topic/6357-a-book-about-object-pascal-style-guide/?do=findComment&comment=55267 Share this post Link to post
Guest Posted March 1, 2022 (edited) YES! it's possible do it! my way around this little obstacle: go to "Tools -> Language -> Formatter -> Profiles and Status" and save your profile to disk! open this file and search for: <Option Name="DelphiFormatter.NewLineForEachVarAndConstElement" Type="Borland.Together.OpenAPI3.Config.LF_CASE" Category="DelphiLinebreaks" SubCategory="NewLines" Value="Yes" Levels="Formatter" /> change the param "Value=Yes" to "Value=No" reload this profile in your IDE using "Profile and Status" option if necessary, close your IDE and re-open it Note: you can catch this dialog after this change and closing your IDE!!! Dont worry, just close it! now, in your code try this: ... var MyVar:string := 'hello world'; // press Ctrl+D to reformat it Edited March 1, 2022 by Guest Share this post Link to post
Attila Kovacs 631 Posted March 1, 2022 5 minutes ago, Uwe Raabe said: The original PDF can be found here The original PDF has -who know how much- more pages so it's not on the page 71, as I said, it's almost impossible to find his reference after making a slapstick comedy from that document. Share this post Link to post
emileverh 22 Posted March 1, 2022 55 minutes ago, joaodanet2018 said: YES! it's possible do it! my way around this little obstacle: go to "Tools -> Language -> Formatter -> Profiles and Status" and save your profile to disk! open this file and search for: <Option Name="DelphiFormatter.NewLineForEachVarAndConstElement" Type="Borland.Together.OpenAPI3.Config.LF_CASE" Category="DelphiLinebreaks" SubCategory="NewLines" Value="Yes" Levels="Formatter" /> change the param "Value=Yes" to "Value=No" reload this profile in your IDE using "Profile and Status" option if necessary, close your IDE and re-open it Note: you can catch this dialog after this change and closing your IDE!!! Dont worry, just close it! now, in your code try this: ... var MyVar:string := 'hello world'; // press Ctrl+D to reformat it Thanks for the large explanation, but did not do the job still...... ;-(( Strange!! <Option Name="DelphiFormatter.NewLineForEachVarAndConstElement" Type="Borland.Together.OpenAPI3.Config.LF_CASE" Category="DelphiLinebreaks" SubCategory="NewLines" Value="No" Levels="Formatter" /> Share this post Link to post
Guest Posted March 1, 2022 (edited) my IDE is RAD 11 and do it! do you put the "type" in var definition? var VARx : TYPE := value; Edited March 1, 2022 by Guest Share this post Link to post
Attila Kovacs 631 Posted March 1, 2022 1 hour ago, joaodanet2018 said: my way around this little obstacle: Ahh, it's you again, emailx45 the warez king and comic book flooder. <o> Share this post Link to post
Darian Miller 366 Posted March 1, 2022 (edited) 2 hours ago, emileverh said: For D11; Can anybody tell me what setting(s) I needin Tools-Options-Language-Formatter ( or may be it's not possible at all ) the format an inline var. I want to have the keyword in front of the variable, now a line break is added. By the way the line break is not added in a 'regular' declaration Inline variables were introduced with 10.3 back in 2018 and the tooling has not been updated yet to properly support them. I currently lump them in with GOTO and WITH statements. From my style guide: Do not utilize inline variables (first introduced in 10.3 in November 2018) until the tooling catches up. Some examples include: RSP-32507 Inline variable breaks the Methods drop-down box in Navigation Toolbar RSP-33176 Extract method refactoring broken by inline var definition RSP-33365 In-block variables break the "Find references" RSP-23096 Incorrect debugger values RSP-22089 Code Formatter Fails on Inline Vars See note from Marco on RSP-28948: May 14, 2020 The formatter is not related with CodeInsight and LSP and is an area we plan addressing next. GExperts is the way to go for now. It would be great to use the built-in formatter and then most of arguments/variances on formatting could be solved by using a shared formatter config file. (You don't argue, you simply hit CTRL-D, or do it automatically before check-in with the command line tool.) Edited March 1, 2022 by Darian Miller Share this post Link to post
Stano 143 Posted March 1, 2022 1 hour ago, Attila Kovacs said: Originál PDF má - ktovie koľko - viac strán, takže nie je na strane 71, ako som povedal, je takmer nemožné nájsť jeho referenciu po tom, čo z toho dokumentu urobíte grotesku. There is content for that. Share this post Link to post
Guest Posted March 1, 2022 hi @Darian Miller here in RAD 11 the reformating var inline in same line is working as showed above Share this post Link to post
Darian Miller 366 Posted March 1, 2022 4 hours ago, joaodanet2018 said: hi @Darian Miller here in RAD 11 the reformating var inline in same line is working as showed above There are multiple issues with inline variables... I provided a partial list. It does work in some cases. Share this post Link to post
emileverh 22 Posted March 2, 2022 12 hours ago, joaodanet2018 said: my IDE is RAD 11 and do it! do you put the "type" in var definition? var VARx : TYPE := value; No I did not.... And for me(!) is it not necessary to include the type Share this post Link to post
Stano 143 Posted March 2, 2022 Yes. There are situations where the compilator doesn't know / cannot determine the data type. Share this post Link to post
emileverh 22 Posted March 2, 2022 3 hours ago, Stano said: Yes. There are situations where the compilator doesn't know / cannot determine the data type. How do you notice that?! Is the compiler complaining or do you have runtime issues? Share this post Link to post
Stano 143 Posted March 2, 2022 (edited) The code does not work. I immediately realized why. I use TVirtualStringTree (VST). That data is stored in the record. I have it defined as follows PTableData = ^ TrTableData; TrTableData = record Booleans: TList <Boolean>; Currencys: TList <Currency>; Dates: TList <TDate>; Integers: TList <Integer>; Others: TList <Variant>; Strings: TList <string>; end; For each VST, its structure is different. Some lists will not be created at all. Therefore, the following fails: var NodeData: = VST.GetNodeData (Node); It must be var NodeData: PTableData: = VST.GetNodeData (Node); Edited March 2, 2022 by Stano Share this post Link to post
Guest Posted March 2, 2022 (edited) 21 hours ago, Attila Kovacs said: Ahh, it's you again, emailx45 the warez king and comic book flooder. <o> That insight took quite some time for you. I had you pinned as an observant person. You'll have to work you way up again 🙂 Edited March 2, 2022 by Guest Share this post Link to post
Attila Kovacs 631 Posted March 2, 2022 3 minutes ago, Dany Marmur said: I had you pinned as an observant person. Haha, thx Dany, I have to admit I'm really busy with other things these days and also, his avatar mesmerizes me all the time I'm seeing it. But I'll keep an eye on him from now on 😄 Share this post Link to post
Guest Posted March 2, 2022 5 minutes ago, Attila Kovacs said: Haha, thx Dany, I have to admit I'm really busy with other things these days and also, his avatar mesmerizes me all the time I'm seeing it. But I'll keep an eye on him from now on 😄 It is enough if you keep an eye on your own posts. Piece, shalom and salaam, brother! (i am the reporter). Share this post Link to post