Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2022-03

Adding unit automatically adds to uses clause

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Timothy Groves

Good day.? When I click on "New Pascal Unit" on the toolbar, or select it from the menu, the new unit is automatically added to the uses clause of my main program.? Worse, the new unit is invariably added as "unit1", even after I change the name of the unit.? I cannot seem to find a way to suppress this behaviour. Can anyone tell me how to stop Lazarus from doing this?

Reply by email

Martin Frb
to Timothy Groves
Timothy Groves wrote 7 lines
Good day.? When I click on "New Pascal Unit" on the toolbar, or select it from the menu, the new unit is automatically added to the uses clause of my main program.? Worse, the new unit is invariably added as "unit1", even after I change the name of the unit.? I cannot seem to find a way to suppress this behaviour. Can anyone tell me how to stop Lazarus from doing this?

I am not aware how to entirely to disable this.

About renaming.
If you do "Save Unit as" and enter a new name, then it should rename the unit in other units "uses" clauses.

IMHO, I consider it a bug that it does not update other units, if you change the name in source code before you save the unit for the very first time.

Obviously, once you saved the unit, you must do "save as" to rename it. Otherwise the name in the source, and the filename will not match.

Reply by email

Timothy Groves
to Bart

Yep, that did the trick.? Thanks!

Bart wrote 8 lines
Project->Options->Miscalleneous: uncheck "Main unit has uses section containing all units of a project." I think this is a per project setting and not globall. -- Bart

Reply by email