Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
parsing code files to identify dependencies?
#1
From time to time I run into this issue where 
  • I have a program with multiple modules (in QB64, VBA, VBScript, etc.) containing some functions or routines I want to reuse in another program
  • Various routines call other routines, and there is a dependency chain.
  • So I end up having to copy one function at a time, try to compile, see what functions or variable definitions the IDE complains is missing, copy that over, test again, and so on. 
  • For bigger projects, this can take up some time and gets pretty tedious.

If anyone has found any tools or written a script that can parse multiple files of QB-like code, making a map of what functions are contained in each, and parse them all to see what functions they call, so that for function X to work somewhere else, will produce a list of all the routines you'll need to move over (including their dependencies, and so on), I would be interested in hearing about it!
Reply
#2
Set up your functions to be LOAD_ONCE, like so:


$IF MYFUNC_FOO = UNDEFINED THEN
   $LET MYFUNC_FOO = TRUE
    Function Foo
        Foo = 123
    End Function
$END IF


The above can only load once (while your precompiler variable is undefined), and then it'll never load again (due to the $LET defining the variable).  Like this, you assure that a routine only loads once and you avoid the glitches of trying to load it multiple times into your main program.
Reply
#3
(03-23-2023, 09:29 PM)SMcNeill Wrote: Set up your functions to be LOAD_ONCE, like so:
...
The above can only load once (while your precompiler variable is undefined), and then it'll never load again (due to the $LET defining the variable).  Like this, you assure that a routine only loads once and you avoid the glitches of trying to load it multiple times into your main program.

Thanks - this will come in handy. 

But what I am talking about is more about programmatically analyzing code to learn what dependencies exist on custom functions, to know what subset of code to copy over, to eliminate unused code - quite the opposite of LOAD_ONCE, which is the approach of including everything and the programming environment won't blow up from duplicates. 

Also, this is for cleaning up more than QB64/PE programs, I have a need for this on a daily basis with VBA and VBScript. 

Anyway, thanks for your reply, I will file the LOAD_ONCE in my recipe box, you never know when something like that might come in handy!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  VS Code and Qb64 pe Unseen Machine 6 719 09-03-2025, 09:42 PM
Last Post: grymmjack
  has anyone had ChatGPT write QB64 code yet? madscijr 13 2,915 08-23-2025, 09:15 AM
Last Post: doppler
  liquid code experiment madscijr 3 487 06-20-2025, 07:26 PM
Last Post: madscijr
  [split] Lines of Code bplus 20 2,991 01-25-2025, 05:11 PM
Last Post: Pete
  QB64 GPT Just Rewrote My Code SpriggsySpriggs 17 2,788 05-30-2024, 06:50 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)