TODO ToDoesn't lazarus / 9-Editor ---------------------------------------------------------------------- Bazzao · 2019-07-06 03:43 TODO seems to work in unit1.pas and sometimes elsewhere. I have placed some TODOs in other units / classes / includes, but they do not appear, even when refreshing.  Is this a bug, or is there some setting that needs to be tweaked? Bazza ---------------------------------------------------------------------- Handoko · 2019-07-06 03:54 Mine seems to work correctly. I'm using Lazarus 2.0.2 Linux. ---------------------------------------------------------------------- Martin_fr · 2019-07-06 08:42 Are the other units part of the project (listed in the project inspector)? Or part of any package? Not sure how, but IIRC there should be a way to get todo for a package. ---------------------------------------------------------------------- lucamar · 2019-07-06 10:33 Quote from: Martin_fr on July 06, 2019, 10:42:46 amOr part of any package? Not sure how, but IIRC there should be a way to get todo for a package. Not for a package but for all used packages. Just tick the "Packages" checkbox in the Todo viewer. Note that to be listed the "todos" must be either:Listed in the project inspector/package editor;Used in the main source file;Opened in the editor; orLike 1 and 2 but in some package used in the project.and, of course, the corresponding checkbox in the viewer must be ticked.. ---------------------------------------------------------------------- Thaddy · 2019-07-06 11:16 You can replace {%TODO} with {$ERROR}....... Freepascal also allows user defined errors or warnings.... Manuals.... Note % is Lazarus specific..... ---------------------------------------------------------------------- lucamar · 2019-07-06 15:08 Quote from: Thaddy on July 06, 2019, 01:16:56 pmYou can replace {%TODO} with {$ERROR}....... Freepascal also allows user defined errors or warnings.... Manuals.... Note % is Lazarus specific..... Ah... he's, I think, referring to "normal" TODOs, as in: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {TODO 9 -olcm -cbase : Implement this method at once!} In fact, now I think of it ... what is "%TODO"? I can't find it in the docs ---------------------------------------------------------------------- howardpc · 2019-07-06 16:40 Some years ago you could insert "todo"s in the Lazarus IDE using the syntax  {%todo a todo comment} This functionality was removed (I don't recall when). Presumably it caused conflicts with other uses of %-based IDE directives. I don't think anyone noticed. Not a great loss. You still have all these options:Code: [Select]{TODO todo text} {#todo  todo text} { ToDo todo text} // Todo: todo text (* todo: todo text *) ---------------------------------------------------------------------- Bazzao · 2019-07-10 04:05 Quote from: Martin_fr on July 06, 2019, 10:42:46 amAre the other units part of the project (listed in the project inspector)? Or part of any package? Not sure how, but IIRC there should be a way to get todo for a package. There were none includes listed. I had wiped out all the todos, and then when I saw your reply just now, added the portions to the Inspector, but there was noting to show. So I opened up another Project, added a dummy ToDo in each of the includes, ans they all showed, without being  included in the Inspector. I can't explain it, but I now know to possibly include the file in the inspector. ---------------------------------------------------------------------- Bazzao · 2019-07-10 04:07 Must be for a later version of Lazarus. I think it's time I upgraded. Bazza ---------------------------------------------------------------------- Bazzao · 2019-07-10 04:09 Quote from: lucamar on July 06, 2019, 05:08:32 pmQuote from: Thaddy on July 06, 2019, 01:16:56 pmYou can replace {%TODO} with {$ERROR}....... Freepascal also allows user defined errors or warnings.... Manuals.... Note % is Lazarus specific..... Ah... he's, I think, referring to "normal" TODOs, as in: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {TODO 9 -olcm -cbase : Implement this method at once!} In fact, now I think of it ... what is "%TODO"? I can't find it in the docs "TODO 9 -olcm -cbase : Implement this method at once!" is the ToDo I am using. Bazza ---------------------------------------------------------------------- Thaddy · 2019-07-10 07:38 I actually mean something different: not a {todo}, but using user defined hints, warnings or errors. Some todo's need a hint, {$hint this is not fully implemented} Some todo's need a warning, {$warning this needs to be implemented or is a hack} Some todo's must generate an error. {$error  this is not finished} See? If you use these very obvious tools, you can create a "todo'" that the compiler itself warns you for or even stop compiling if the code really needs to be completed. E.g:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program testtodo;{$mode objfpc} uses  Sysutils,Classes;var  S: TStringList; begin  {$hint need explanation}  S := TStringList.Create;  S.LoadFromFile('test.pas',TEncoding.Utf8);  writeln(S.Text);  {$warning no free yet}  S.Free;  {$error this is not finished yet, get back to work}end. Outputs:Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Compiling test.pastest.pas(11,4) Hint: User defined: need explanationtest.pas(15,4) Warning: User defined: no free yettest.pas(17,4) Error: User defined: this is not finished yet, get back to worktest.pas(19) Fatal: There were 1 errors compiling module, stoppingFatal: Compilation aborted  There's your todo's...... Toodles, Thaddy ---------------------------------------------------------------------- howardpc · 2019-07-10 08:05 Quote from: Thaddy on July 10, 2019, 09:38:36 amIf you use these very obvious tools, you can create a "todo'" that the compiler itself warns you for or even stop compiling if the code really needs to be completed. The messages produced in this case are not the "compiler itself" warning you (except in some trivial mechanical way) but the programmer sending himself a warning, via a {$xxx } directive of a condition he was aware of as he wrote the code. I don't see how that adds much value compared to the use of a "// todo: you need to do..." The IDE collects all these messages conveniently in one place so you can check off outstanding issues. It allows you to jump directly to the relevant line in the source, and also provides a way (// done) to dispose of the messages too as you deal with them at your convenience, while retaining a record of tasks completed. ---------------------------------------------------------------------- Thaddy · 2019-07-10 08:30 Quote from: howardpc on July 10, 2019, 10:05:27 amThe messages produced in this case are not the "compiler itself" warning you (except in some trivial mechanical way) but the programmer sending himself a warning, via a {$xxx } directive of a condition he was aware of as he wrote the code. I don't see how that adds much value compared to the use of a "// todo: you need to do..." The crux of the question is not about commenting code, but about not forgetting something. This is actually crucial in teams or larger projects. I just wanted to demonstrate that such features are available and very easy to use. So it adds a lot of value in my opinion. That's why these features are there.... A comment will not show up in the compiler output.... My examples will... I hope that changes your mind... ---------------------------------------------------------------------- lucamar · 2019-07-10 12:10 I think both have its uses, depending on the circumstances. If you're not really happy with somethng you can add a: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { TODO : Not really happy with this; merits a little more thought for the revision}but if you added a kluge somewhere because you were in a hurry a Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$WARNING Terrible kluge combined with magic here! Set to rights ASAP!}might be more appropiate. A question of point of view, I guess ---------------------------------------------------------------------- Thaddy · 2019-07-10 14:18 Quote from: lucamar on July 10, 2019, 02:10:24 pmIA question of point of view, I guess Yes, the extra effort of typing a dollar sign can be a point of view? ---------------------------------------------------------------------- lucamar · 2019-07-10 15:31 Quote from: Thaddy on July 10, 2019, 04:18:00 pmQuote from: lucamar on July 10, 2019, 02:10:24 pmIA question of point of view, I guess Yes, the extra effort of typing a dollar sign can be a point of view?  Nah, I mean deciding whether something merits a warning from the compiler or a TODO note suffices. Also, if one looks closely, a TODO is more work than a simple $warning ---------------------------------------------------------------------- Kays · 2019-07-10 16:19 Quote from: Thaddy on July 10, 2019, 09:38:36 am[…] {$warning this needs to be implemented or is a hack}[…]Also, there exist hint directives likeunimplemented or experimental. ---------------------------------------------------------------------- Bazzao · 2019-07-12 02:08 Quote from: Thaddy on July 10, 2019, 09:38:36 amI actually mean something different: not a {todo}, but using user defined hints, warnings or errors. Some todo's need a hint, {$hint this is not fully implemented} Some todo's need a warning, {$warning this needs to be implemented or is a hack} Some todo's must generate an error. {$error  this is not finished} See? If you use these very obvious tools, you can create a "todo'" that the compiler itself warns you for or even stop compiling if the code really needs to be completed. E.g:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program testtodo;{$mode objfpc} uses  Sysutils,Classes;var  S: TStringList; begin  {$hint need explanation}  S := TStringList.Create;  S.LoadFromFile('test.pas',TEncoding.Utf8);  writeln(S.Text);  {$warning no free yet}  S.Free;  {$error this is not finished yet, get back to work}end. Outputs:Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Compiling test.pastest.pas(11,4) Hint: User defined: need explanationtest.pas(15,4) Warning: User defined: no free yettest.pas(17,4) Error: User defined: this is not finished yet, get back to worktest.pas(19) Fatal: There were 1 errors compiling module, stoppingFatal: Compilation aborted  There's your todo's...... Toodles, Thaddy Yes, I know about $Hints, however they can be filtered upon compile. $Warning is new to me. ---------------------------------------------------------------------- Bazzao · 2019-07-12 02:12 Quote from: lucamar on July 10, 2019, 02:10:24 pmI think both have its uses, depending on the circumstances. If you're not really happy with somethng you can add a: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i { TODO : Not really happy with this; merits a little more thought for the revision}but if you added a kluge somewhere because you were in a hurry a Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$WARNING Terrible kluge combined with magic here! Set to rights ASAP!}might be more appropiate. A question of point of view, I guess Ahhh, a new term kluge [kludge]. I had to look that up. ToDos Vs $Hint & $Warning: * You can click on a ToDo and it will take you to the code. B