What unit contains this object? lazarus / 21-General ---------------------------------------------------------------------- dgrhoads · 2021-01-19 13:07 One thing I love about Lazarus is the documentation, especially the lists of objects for the rtf, FCL and LCL.  It took me a while to figure out how it all goes together.  Having done that, it makes things a whole lot easier. One thing that I don't see in the descriptions of those objects (i.e. TStringGrid or TINIFiles), is which unit they are located.  If the object were in a package, it would be loaded automatically into the uses statement.  In many cases, there is no package as the object is not visual. Is there an easy way to figure out the unit in which a given object is located? ---------------------------------------------------------------------- Handoko · 2021-01-19 13:23 If you use Lazarus IDE, you can move your mouse above the identifier and use Alt + Click. It does not show/tell you which unit the identifier belong to but it shows you which file (not always *.pas, it can be *.inc) the declaration of it can be found. Alt + Click does not always available, for example you haven't put the correct unit in the uses clause. ---------------------------------------------------------------------- Martin_fr · 2021-01-19 13:35 Quote from: dgrhoads on January 19, 2021, 02:07:09 pmOne thing that I don't see in the descriptions of those objects (i.e. TStringGrid or TINIFiles), is which unit they are located. https://lazarus-ccr.sourceforge.io/docs/lcl/grids/tstringgrid.html QuoteDeclaration Source position: grids.pas line 1761 https://www.freepascal.org/docs-html/fcl/inifiles/tinifile.html QuoteDeclaration Source position: inifiles.pp line 215 Look at the URL to see the package it is in: LCL and FCL. You can add the package to your project, type the unit into your uses clause, and then use the IDE to jump to the unit. There is also a nice tool "Identifier dictionary" Under Packages > Install Packages: Install the packages "Cody" into your IDE. You get a new menu entry "Show Unit/Identifier dictionary" in the "Source" menu. It can find almost any identifier, and tell you where it is declared. If it does not find something, it will learn as you manually discover it... (afaik) ---------------------------------------------------------------------- cdbc · 2021-01-19 14:20 Hi On my Lazarus, i just have to 'hover' the mouse over the identifier and up pops a bobble with the information you need. Clever, right  HTH Regards Benny ---------------------------------------------------------------------- Martin_fr · 2021-01-19 14:41 The "alt click" and "hover" work fine, if the correct unit is already in the uses. If you start a new empty project, and you insert "var a: TWriteInstruction" then you still need to add the unit where this is declared. And "alt click" and "hover"  will not tell you anything. The identifier dictionary might find it. It may not always. Afaik it learns over time.... ---------------------------------------------------------------------- wp · 2021-01-19 14:54 Quote from: Handoko on January 19, 2021, 02:23:15 pmAlt + Click Really? I use Ctrl+Click. ---------------------------------------------------------------------- Martin_fr · 2021-01-19 15:02 Quote from: wp on January 19, 2021, 03:54:28 pmQuote from: Handoko on January 19, 2021, 02:23:15 pmAlt + Click Really? I use Ctrl+Click. Ok, yes... In my case thoughtless  copy and paste.... Alt - cursor- up.... Though you can configure the mouse to work with alt-click. Never mind: Ctrl click will not find you TWriteInstruction, unless the unit is in the uses (and the package in the project) ---------------------------------------------------------------------- dgrhoads · 2021-01-19 19:59 So the bottom line is that if the correct unit is not listed on the uses section, I have to figure out what unit to include using whatever resources I can muster. I had a feeling that was the case.  I was hoping that there was a better solution. I know that it would be a tremendous amount of work at this stage, but it would be nice to update the documentation so that the name of the unit is included in the description. ---------------------------------------------------------------------- Martin_fr · 2021-01-19 20:05 Quote from: dgrhoads on January 19, 2021, 08:59:52 pmSo the bottom line is that if the correct unit is not listed on the uses section, I have to figure out what unit to include using whatever resources I can muster. No, the identifier directory will do that. Eventually. I do not know its exact inner working, and when exactly it builds the dictionary. I heard (hearsay) some people had to wait until it would build the dictionary. For me it always worked on the spot. Of course the IDE has to have access to the source. It will not tell you, if the identifier is in a package you have not yet downloaded.