David Heffernan 2345 Posted October 12, 2022 13 hours ago, Ian Branch said: Or perhaps.. MyDialog := TTaskDialog.Create(Self); MyDialog.Title := 'Warning!'; MyDialog.Text := 'Relevant/selected Records prior to ' + sArchivedDate + ' have been Archived!' + #13 + 'This may make the figures inaccurate!'; MyDialog.CommonButtons := [tcbOk]; try MyDialog.Execute; finally MyDialog.Free; end; This blows my mind. The try/finally is to protect the resource. So you must enter the try immediately after the resource has been acquired. I suggest that you read Dalija's book on memory management. 2 Share this post Link to post
Fr0sT.Brutal 900 Posted October 13, 2022 (edited) 22 hours ago, Sherlock said: Nonono, of course not. I just wanted to weaken the "it's just another tool in the box" argument. Goto is an another tool in the box as well 😉 Mainly for highly-optimized routines though (FastCode's functions are full of them). However I never needed it myself in my code Edited October 13, 2022 by Fr0sT.Brutal Share this post Link to post
Mike Torrettinni 198 Posted October 16, 2022 On 10/11/2022 at 6:23 PM, Ian Branch said: The passion behind not using 'with' is interesting. Also interesting is that I see no advocates. Yes, yes, you will say "And the reason is....". 🙂 To me it is just another tool in the tool box of the language. I can see and understand where concerns may be but as with any tool, used correctly, there is no issue. When I was using With a lot, I had the same view about With. But as it was already mentioned, a big disadvantage is using debugger with such a code. Very cumbersome, so I removed all With usage, except for a few basic forms, as in your example, for simple ShowModal - and these are in the process to be removed from using With, too! Do you use Virtual Treeview (TVirtualStringTree), have you ever looked into the code or try to figure it out? The usage of With is in every other method, including nested With! Such a great component, so incompatible with debugger! Share this post Link to post