|
Post by (X) on Jun 3, 2023 20:13:24 GMT 1
I am looking for a way to generate a list using code of all the subs, procedures and functions in a GFA-Basic 32 for Windows program.
Anybody know how?
I know CallTree will let us know the current sub/proc/func and even the ones that called the current one.
I guess I could create a GLL that does a search in the current program for any word that comes after:{Sub, Proc, Procedure, Function} and print them to the debug window or puts them in a collection... Hmmm.
Any better ideas?
|
|
|
Post by dragonjim on Jun 3, 2023 22:01:15 GMT 1
You can load the .g32 file into the program as a string and do a search for the words Proc[edure], Sub (make sure it is not the command) and Func[tion]. Discount any lines that start with a comment and any keywords which do not have a space after them.
I use this method for updating common files in old program listings.
|
|
|
Post by dragonjim on Jun 3, 2023 23:43:45 GMT 1
Below is a quick sample program of how to send procedure, function and sub names to the Debug window: GetProcNames.g32 (965 B)
|
|
|
Post by (X) on Jun 4, 2023 1:14:28 GMT 1
Well that works a treat! I'm gonna try to build a Treeview Of Sub, Proc, Function names and the vars they contain.
|
|
|
Post by dragonjim on Jun 4, 2023 10:03:09 GMT 1
That sounds doable - and useful. You could scan for any variable after a Dim, Static, Local, Global, Private or Public declaration the same way as for routine names.
One useful application would be to determine how often the variable is used (Local within the routine, Global within the program itself) so it would be possible to root out any unused or underused variables when optimising a program or routine.
Watch out for Dim though; as I'm sure your aware, it is Global if used in the root or main routine and Local if used in a sub routine.
|
|