Recent

Author Topic: Code Creation options not working  (Read 4284 times)

HatForCat

  • Sr. Member
  • ****
  • Posts: 293
Code Creation options not working
« on: March 26, 2013, 09:09:59 pm »
Hi,

I have set the options for "Last" as I want to define the order. Unless I am misunderstanding something, then this option is not working.

When I start a new Form I first set the 6 Procedures that are important to me and in the order they happen.

Create;
Activate;
Show;
CloseQuery;
Close
Destroy:

I am damned if I can find an option in the Tools - Options - Code Tools - Code Creations that will do this.

Is it me or Lazarus?

I want those things where I want them. :)

{edit}
It puts them in Alphabetically no matter what I set. HELP!! :)
{/edit}
« Last Edit: March 26, 2013, 09:31:12 pm by HatForCat »
Acer-i5, 2.6GHz, 6GB, 500GB-SSD, Mint-19.3, Cinnamon Desktop, Lazarus 2.0.6, SQLite3

howardpc

  • Hero Member
  • *****
  • Posts: 3614
Re: Code Creation options not working
« Reply #1 on: March 26, 2013, 10:50:37 pm »
The "Alphabetically" option applies only to the ordering of units used, it does not affect the order of procedures.
Make sure the check box
  [ ] Keep order of procedures
is checked.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6821
  • Debugger - SynEdit - and more
    • wiki
Re: Code Creation options not working
« Reply #2 on: March 27, 2013, 02:05:28 am »
I don't think it is currently configurable.

But if it was, that would have probably been the option: http://wiki.lazarus.freepascal.org/IDE_Window:_Codetools_Options#Class_part_insert_policy

AFAIK: It only applies to code completion (shift-ctrl-C)

If you have
    OnActivate := @MyActivate;
and press Shift-Ctrl-C on MyActivate, then MyActivate is eitehr added to the end, or alphabetically.

See also http://wiki.lazarus.freepascal.org/Lazarus_IDE_Tools#Code_Completion for what else code completion can do.

---

I have no idea if it is intention or oversight, but it does not affect designer/Object-Inspector edits.

HatForCat

  • Sr. Member
  • ****
  • Posts: 293
Re: Code Creation options not working
« Reply #3 on: March 27, 2013, 02:42:58 am »
Thanks, it is all a bit of a mess. It keeps moving stuff about and duplicating procedures I am writing. I have as much of the Code completion turned off as I can find possible, but it seems to ignore some settings. I found that I had to close and restart Lazarus and some of them worked.

I don't think Lazarus is ready for the big time. This is very frustrating. I have "Keep order" checked, but as soon as I do a test compile I get "Overload" errors as it has just recreated empty procedures I have declared in the Private and Public sections. Even though I have just finished writing them myself.

It seems like I have to use the procedure it creates from the Private and Public sections. Delphi is not looking so bad right now. :( That's a bummer because I had great hopes for this, but it is just too user unfriendly.

There are a lot of little user-interface things that are not working as they should. Sometimes they do, sometimes they don't and there doesn't seem to be a reason why or why not.

Thanks for taking the time to answer though.

Acer-i5, 2.6GHz, 6GB, 500GB-SSD, Mint-19.3, Cinnamon Desktop, Lazarus 2.0.6, SQLite3

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6821
  • Debugger - SynEdit - and more
    • wiki
Re: Code Creation options not working
« Reply #4 on: March 27, 2013, 03:18:36 am »
I see the aesthetic (re-ordering) issue.

You can always put it as a feature request on mantis (or maybe it is unintended (aka a bug)).

I am not sure where you get the duplicates.
However something else troubles me here.
Quote
It seems like I have to use the procedure it creates from the Private and Public sections

Do you mean you move the
Code: [Select]
  Procedure Form1Activated(...) // assigned to OnActivate via object inspector
into a public or private section?

Because that will not work. It is created in a published (the first block of TForm (which has no visibility keyword) is published).
And it must be published.

The code loading the TForm will not find it, if it is not published.

HatForCat

  • Sr. Member
  • ****
  • Posts: 293
Re: Code Creation options not working
« Reply #5 on: March 27, 2013, 06:04:55 pm »
Hi Martin,

No, what I do is go to the Private or Public section and create the procedure header, say...
procedure PushThis(aStr : String);
and I then mark and copy that header to the clipboard.

I then go to the bottom of the file and just before the "end." I paste the procedure and add the Form.Name
procedure TForm1.PushThis(aStr : String);
begin
  // Fill MY  stuff in here
end;

Now when I hit Fast Compile I get an Overload error with matching headers. I go to the code and find this...

procedure TForm1.PushThis(aStr : String);
begin

end;

procedure TForm1.PushThis(aStr : String);
begin
  // Fill MY stuff in here
end;

Lazarus has created the empty copy of the procedure so now there are two identical procedure headers and naturally an Overload error results. I then have to go to the empty procedure Lazarus created and delete it and all is well from that point. It seems it has to create that open procedure just once and it is happy.

So, what I am saying, is that rather than create my own procedures, I have to wait until Lazarus creates it's empty version and use that.

It is a pain in the butt. I am sure the developers think it is a neat convenience feature, but to someone who has been programming for 35+ years -- a pain in the butt.
Acer-i5, 2.6GHz, 6GB, 500GB-SSD, Mint-19.3, Cinnamon Desktop, Lazarus 2.0.6, SQLite3

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Code Creation options not working
« Reply #6 on: March 27, 2013, 06:13:30 pm »
In fact you need to press Ctrl+Shift+C in order to make Lazarus create the empty procedure for you.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6821
  • Debugger - SynEdit - and more
    • wiki
Re: Code Creation options not working
« Reply #7 on: March 27, 2013, 10:46:41 pm »
No, what I do is go to the Private or Public section and create the procedure header, say...
procedure PushThis(aStr : String);
and I then mark and copy that header to the clipboard.

I then go to the bottom of the file and just before the "end." I paste the procedure and add the Form.Name
procedure TForm1.PushThis(aStr : String);
begin
  // Fill MY  stuff in here
end;

Now when I hit Fast Compile I get an Overload error with matching headers. I go to the code and find this...

Ok, that should not happen. And I still was not able to reproduce.

As typo said:
Quote
In fact you need to press Ctrl+Shift+C in order to make Lazarus create the empty procedure for you.

Did you do that at any time?

If you for example:
* type the declaration,
* and then (before creating the body) would press Ctrl+Shift+C
* and then create your own body
then you had 2 bodies. Because Ctrl+Shift+C would have created it, because it was not there at that time.

The same happens, if you add an event (in the object inspector, or by double clicking a component or the form
* type the declaration,
* and then (before creating the body) would add an event (double click the form, or double click an event in OI)
* and then create your own body
again leads to 2 bodies

When adding an event, then the IDE auto-completes your TForm class. That is, it creates bodies for all declared methods if they have not yet one.




The IDE should never create the body, if it does already exist. If so, then we need a good step by step to reproduce that.

Also note: the IDE will update the declaration of the body, if you change it in the interface, and trigger code completion.

« Last Edit: March 27, 2013, 10:50:27 pm by Martin_fr »

 

TinyPortal © 2005-2018