List of Variablen in Code?
List of Variablen in Code?
Is there a tool or function that searches a project for which variables exist and how they are declared, including Define & Global?
thx TFT
thx TFT
TFT seid 1989
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMagic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMagic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak

Re: List of Variablen in Code?
I recall some past discussions about this — it would be nice if the PureBasic compiler made the symbol table available in the form of output. I'm not sure if that is possible. In particular, I would love to see an unused variable warnings list, as this was always a standard practice of compilers in the past, where, for reasons of code refactoring for instance, we had perhaps defined a variable but no longer use it.
- Michael Vogel
- Addict
- Posts: 2808
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: List of Variablen in Code?
Tried all these tools but never was absolute happy with them.
The 'Unused Vars' searcher seems to be very precise (and scans 200% of the source
) but fails for code lines like r=2*mmm : mmm=r+bb+bb.
The 'Variable Renamer' is quite fast (except filling the ListIconGadget with the results) but show results like ?DataPosition, @XYZ and XYZ or sometimes special characters or non existent variables like Ascii.
Anyhow this tool seems to be a good start - maybe some more information about the variables like the type (integer, string,...) or its position (line number or procedure) would be fine, as well a quick jump to it's (first) location in the source code.
The 'Unused Vars' searcher seems to be very precise (and scans 200% of the source

The 'Variable Renamer' is quite fast (except filling the ListIconGadget with the results) but show results like ?DataPosition, @XYZ and XYZ or sometimes special characters or non existent variables like Ascii.
Anyhow this tool seems to be a good start - maybe some more information about the variables like the type (integer, string,...) or its position (line number or procedure) would be fine, as well a quick jump to it's (first) location in the source code.
Re: List of Variablen in Code?
Is that because of the colon? Perhaps the parser needs to separate any lines with colons into their own lines before parsing.
- Michael Vogel
- Addict
- Posts: 2808
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: List of Variablen in Code?
No, I've had inserted two lines in fact (just summarized them for the posting).
I saw also some other issues - for instance not only variables but also procedures are shown in the list. Of course, these procedures have been called from the program.
I saw also some other issues - for instance not only variables but also procedures are shown in the list. Of course, these procedures have been called from the program.
Re: List of Variablen in Code?
It looks like I'll have to write something myself. I did this once 15 years ago. But I no longer have the code. As part of my game project, I need to have something like this. Maybe someone will still get in touch. The procedure is not that difficult. First, remove all unnecessary tabs and spaces. Also, do this for all include files. Then list the procedure and macro names. Then the function names, which can be obtained from the compiler executable. Exclude all keywords. If you explicitly assume as a condition. Everything has already been defined somewhere. Consider brackets and quotation marks. If something like this doesn't already exist, I guess I'll have to create it myself. Does anyone else need it?
TFT
TFT
TFT seid 1989
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMagic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak
Aktuelles Projekte : Driving School Evergarden
YouTube : Pure Basic to go
FaceBook : Temuçin SourceMagic Games
DISCORD : SourceMagic
W10 , i9 9900K ,32 GB Ram , GTX Titan , 3 Monitore FHD
ARDUINO Freak

Re: List of Variablen in Code?
I tried a bunch of times over the years but the Tool system has no way to jump to another opened TAB. I think freak said it would be made available at some point and he suggested opening a file in the Tool since that would make the newly opened file the active tab. But, that is tricky with large code files and what if the variable exists in multiple includes?
Now that the IDE is open source, maybe the FindInFiles dialog can be customized to support variable search across open/unopened tabs.

The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: List of Variablen in Code?
Uses "PureBasic\SDK\Syntax Highlighting\SyntaxHighlighting.dll", which is a code analyzer (included with PureBasic). Those code elements that are highlighted as variables in the IDE will be captured. Therefore, there is high accuracy here. Next, they are checked for uniqueness and their number is counted as a whole word and as part of a word to show whether there will be collisions. Taking a variable pointer is also printed. You get complete statistics. If the variable occurs 1 time and does not take the variable pointer, then this is what you are looking for (sorting works by columns). But you can have local variables in different functions that are essentially unused, meaning that ideally you would handle each function separately.Michael Vogel wrote: Mon Jul 15, 2024 9:01 am The 'Variable Renamer' is quite fast (except filling the ListIconGadget with the results)
2. When dividing the code into two files, the second file contains universal functions that can be considered as separate files, that is, I do not use a variable in different files, or until I have such complex projects and I think that this is an incorrect division of the project into blocks. Therefore, I do not seek to remake the program to work with a project, that is, with several files.
3. I have few variables so I didn't use (already added)
Code: Select all
SendMessage_(hGadget, #WM_SETREDRAW, 0, 0)
...filling...
SendMessage_(hGadget, #WM_SETREDRAW, 1, 0)
Re: List of Variablen in Code?
It would be nice to have! I tought about sometimes!
Maybe a solution as a Cross-Reference-Tool which you have to activate manually.
You'll get a treeview and/or ListGadget with all Modules, Procedures, Constants, Variables
with a list of the X-Ref.
Like:
Module: "MyTestModule"
Procedures:
MyTestProcedure1
-(and here the X-Ref)
- File: TestProject_Main.pb
-Line 127
- Line 251
-Line 45
MyTestProcedure2