Lazarus

Programming => General => Topic started by: tomitomy on April 12, 2021, 04:09:53 am

Title: [SOLVED, use Cody]How to know which unit a function is defined in
Post by: tomitomy on April 12, 2021, 04:09:53 am
Hello, everyboby. I have a question, does anyone know it?

Sometimes I remember the name of a function or class defined in lazarus, but I don't remember which unit it was defined in. Is there any way that can help me find this unit?
Title: Re: How to know which unit a function is defined in
Post by: mercurhyo on April 12, 2021, 04:15:51 am
oh yeahhh
debug, breakpoints and removing your gloves is the path hehehe
you know i'm mean lool
Title: Re: How to know which unit a function is defined in
Post by: dbannon on April 12, 2021, 04:16:53 am
Wow, if all questions was as easy as this one.

https://wiki.freepascal.org/Cody#Unit_.2F_Identifier_Dictionary

Really, really useful.

Davo
Title: Re: How to know which unit a function is defined in
Post by: lucamar on April 12, 2021, 04:20:01 am
What I usually do is to search for it in the help files. If that doesn't work because there is no help for the function then I grep the sources, which is a PITA but always work. Except for intrinsics and things which require deep compiler magic (like Write()/Read() and such), but those things are usually in System.

Cody is a good tool but it has its shortcomings, not the least of which is that it isn't there by default and one has to install it and generate a new Lazarus, which in Linux usually means double the storage space.
Title: Re: How to know which unit a function is defined in
Post by: mercurhyo on April 12, 2021, 04:22:08 am
point identifier with cursor use [Ctrl] + spacebar or [shift]+[Ctrl]+enter .... what bout gloves and blabla now? shift+ctrl uparrow too
Title: Re: How to know which unit a function is defined in
Post by: lucamar on April 12, 2021, 04:31:07 am
point identifier with cursor use [Ctrl] + spacebar or [shift]+[Ctrl]+enter .... what bout gloves and blabla now? shift+ctrl uparrow too

All of those work only if you already have the unit in the uses clause and the IDE knows where to look. But the question is precisely how to know which unit you should add to your uses to use this or that unit.

I expend easily 10 to 15% of my time looking into the help for LazUtils doing that ("where was that function: FileUtils of LazFileUtils? or was it in the RTL?"). OK, maybe not as much as 10% of the time, but ... :)
Title: Re: How to know which unit a function is defined in
Post by: Martin_fr on April 12, 2021, 04:36:54 am
All of those work only if you already have the unit in the uses clause and the IDE knows where to look. But the question is precisely how to know which unit you should add to your uses to use this or that unit.
Cody works, when the unit is not yet known.

And cody can add the identifier, and at the same time insert the unit into the uses, and if needed add the package to the project.
Title: Re: How to know which unit a function is defined in
Post by: dbannon on April 12, 2021, 04:39:58 am
Cody is a good tool but it has its shortcomings, not the least of which is that it isn't there by default and one has to install it and generate a new Lazarus, which in Linux usually means double the storage space.

The cody dictionary is just a text file, easily transfered between Lazarus, if you are using the same PCP its already there, if you are making a new PCP, just copy it over.  I just installed Lazarus trunk from Git (honestly, I have tried to use SVN, really tried but ...) so all I did was -

Code: Bash  [Select][+][-]
  1. cp .Laz_trunk/codyunitdictionary.txt .Laz_trunk-git/.

I really think cody should be included in bigide. And maybe have a means of changing the location of the dictionary, same as we do for help files ?

@mercurhyo - I think that only works if you have already 'used' the appropriate unit ?

Davi
Title: Re: How to know which unit a function is defined in
Post by: tomitomy on April 12, 2021, 08:01:53 am
Thank you all for help. I installed Cody, it's cool, it soon found what I need, it's very usful.

I checked the dictionary file, it has 147 KB, and will not take up too much space, but I have a question, can I turn off Cody's auto save function? Because I basically won't change Lazarus's unit files, I want the dictionary file to be static and only read when I need it. I don't want my disk to be written data repeatedly, which will reduce the life of my disk.
TinyPortal © 2005-2018