Recent

Author Topic: [SOLVED, use Cody]How to know which unit a function is defined in  (Read 433 times)

tomitomy

  • Full Member
  • ***
  • Posts: 241
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?
« Last Edit: April 18, 2021, 07:38:45 am by tomitomy »

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: How to know which unit a function is defined in
« Reply #1 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
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

dbannon

  • Hero Member
  • *****
  • Posts: 1404
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How to know which unit a function is defined in
« Reply #2 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
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

lucamar

  • Hero Member
  • *****
  • Posts: 4011
Re: How to know which unit a function is defined in
« Reply #3 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

mercurhyo

  • Full Member
  • ***
  • Posts: 201
Re: How to know which unit a function is defined in
« Reply #4 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
« Last Edit: April 12, 2021, 04:25:36 am by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geoforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

lucamar

  • Hero Member
  • *****
  • Posts: 4011
Re: How to know which unit a function is defined in
« Reply #5 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 ... :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7153
  • Debugger - SynEdit - and more
    • wiki
Re: How to know which unit a function is defined in
« Reply #6 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.

dbannon

  • Hero Member
  • *****
  • Posts: 1404
    • tomboy-ng, a rewrite of the classic Tomboy
Re: How to know which unit a function is defined in
« Reply #7 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
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

tomitomy

  • Full Member
  • ***
  • Posts: 241
Re: How to know which unit a function is defined in
« Reply #8 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