Author Topic: Debugging unused variables and arrays  (Read 3763 times)

0 Members and 1 Guest are viewing this topic.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Debugging unused variables and arrays
« on: January 29, 2022, 10:55:31 am »
Lets say you've got a mixture of 30 variables and arrays in your program, is there a way, using the filter feature of $Debug, to identify unused variables and arrays without going one at a time?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Debugging unused variables and arrays
« Reply #1 on: January 29, 2022, 10:57:13 am »
Doesn't the IDE give warnings for unused variables?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Debugging unused variables and arrays
« Reply #2 on: January 29, 2022, 12:54:22 pm »
Doesn't the IDE give warnings for unused variables?

Why yes! yes it does, very helpful in cleaning up clutter.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Debugging unused variables and arrays
« Reply #3 on: January 29, 2022, 02:33:17 pm »
Yes, before Debug came along, the IDE and it's messages and warning was my main go to for debugging.

Seem to me the list of unused variables and array provided by the IDE only came at a successful run through of the program. When I have a lot of lines of buggy code, and I have lost track of variables and arrays I have altered or abandoned along the way, I have been using our new Debug feature to find those variables (or Array with the first index) that have a value of zero and repurpose them. The problem that catches me is that the variable or array could be vital and just sitting at zero at the exact time I'm calling to see it's value( v's a variable or array which I have inadvertently abandoned).
   The other problem with my use of Debug is the quantity of the variables and arrays. The abandonment or inadvertent loss of use generally is happening when I have lots of variables and arrays. I need to "Select ALL" in Debug but there are too many, so I'll set a break and try to break up the list into smaller groups to seek the unused out.
   I was wondering if there was some method in the filter feature of debug that would do the same thing as the IDE and just list those with a zero value but just up to the point of a set break. I'd need an IF statement in the filter ... IF value = 0 then IMP "Abandoned"

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Debugging unused variables and arrays
« Reply #4 on: January 29, 2022, 02:49:56 pm »
You dont have to Run the code to see what variables and arrays are not being used. The IDE keeps it updated continuously as you write.

Used in combination with Option _Explicit you will save yourself a heap of grieve! Specially if like me, you change variable names as you go in an effort to keep them well named fitting their purpose.

Offline Dimster

  • Forum Resident
  • Posts: 500
    • View Profile
Re: Debugging unused variables and arrays
« Reply #5 on: January 29, 2022, 03:33:16 pm »
I'll abandon my abuse of Debug ... sometimes these sounding boards are just a way to confirm you are once again beating a dead horse.