JonRobertson 72 Posted November 8, 2023 I sent an email to support@mmx-delphi.de. I decided to post here in case someone knows a solution aside from turning off "Auto complete used units" under Pascal->Editing. When adding an event, MMX does not recognize when the required unit is already in the uses clause without a unit scope. For example, adding an event for TDataSet.OnNewRecord adds "Data.DB" to the uses clause, even though "DB" is already in the uses clause. [MMX] FormUsers(12): Auto Completed uses clause. Added: Data.DB On compile/build, this results in: [dcc32 Error] E2004 Identifier redeclared: 'Data.DB' This is a legacy project. Adding unit scopes to each unit reference is on the to-do list. I do feel this is a flaw in MMX that could be corrected if MMX can distinguish the unit scope from the unit name. Jon Share this post Link to post
Uwe Raabe 2057 Posted November 8, 2023 1 hour ago, JonRobertson said: Adding unit scopes to each unit reference is on the to-do list. You can have this for free: Open MMX properties and navigate to Pascal - Sorting Under Format unit uses clauses check Group and sort uses Now when you format the uses clause (with Ctrl-Alt-U while the cursor is inside a uses clause) MMX does the following: Resolve any unit aliases Resolve all unit scope names Group the units as configured (see below) Compress and wrap each group according to the settings The groups are configured per project in the MMX Project options setting. If the entry for Groups is cleared neither grouping nor sorting is done. Also these Project options have an Auto Format checkbox, which when checked forces the uses clause formatting whenever MMX manipulates a uses clause. My personal preference would be to format the uses clauses without any other changes done to keep version control happy. This can be achieved by a command line tool available on GitHub: UsesCleaner It provides almost the same functionality as MMX, but targets complete projects instead of single units. 1 Share this post Link to post
JonRobertson 72 Posted November 8, 2023 Thank you. I am still a new user to MMX and still exploring the options. Unfortunately I have not had time to read the user manual from cover to cover. I am also coming back to the Delphi community after being away (due to job availability) for a couple of years. So I have a little catching up to do. I have not come across UsesCleaner. That sounds like a huge time saver. Share this post Link to post
Uwe Raabe 2057 Posted November 8, 2023 24 minutes ago, JonRobertson said: I have not had time to read the user manual from cover to cover. I'm afraid the user manual doesn't cover this feature. Share this post Link to post
JonRobertson 72 Posted November 15, 2023 On 11/8/2023 at 3:59 PM, Uwe Raabe said: Now when you format the uses clause (with Ctrl-Alt-U while the cursor is inside a uses clause) MMX does the following: Resolve any unit aliases Resolve all unit scope names Group the units as configured (see below) Compress and wrap each group according to the settings I must be doing something wrong. In MMX Properties, Pascal, Sorting, I enabled "Group and sort uses clauses". But Ctrl-Alt-U changes this uses ShlObj, SysUtils, Windows; to this uses Winapi.ShlObj, SysUtils, Windows; and I expected this uses System.SysUtils, Winapi.ShlObj, Winapi.Windows; This is using Delphi 11.3 and MMX 15.1.7 build 2567. Thanks Share this post Link to post
Uwe Raabe 2057 Posted November 15, 2023 Can you show the Unit Scope Names entry in your project options, please? Share this post Link to post
JonRobertson 72 Posted November 15, 2023 Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;System;Xml;Data;Datasnap;Web;Soap;Winapi;Data.Win;System.Win I recently started this position and inherited this project. At the time, was partially migrated from Delphi 7 to Delphi 10. I have not modified the Unit Scope Names in the project as I have not needed to. Share this post Link to post
Uwe Raabe 2057 Posted November 15, 2023 Can you reproduce on a minimal project? I just copied that uses clause into a fresh VCL project and everything works as expected. Share this post Link to post
JonRobertson 72 Posted November 15, 2023 I will attempt to recreate sometime today. Thanks Uwe. Share this post Link to post
JonRobertson 72 Posted November 15, 2023 The behavior in that project was due to the .DPR not having unit scope names in its uses clause. Share this post Link to post
JonRobertson 72 Posted November 22, 2023 I wanted to say that yesterday I took the time to configure MMX to group and sort uses clauses they way I wanted and it is working great. I expect you hear this a lot, but thank you for your help and keeping MMX alive. I did not have the opportunity to use Code Explorer when it was a ModelMaker product. Yesterday I took the time to go through most of the options and will be changing my coding habits to take advantage of more MMX features. 1 Share this post Link to post