Author Topic: Is there a way to get a list of all variables in a program?  (Read 2831 times)

0 Members and 1 Guest are viewing this topic.

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Is there a way to get a list of all variables in a program?
« on: February 15, 2020, 10:55:52 pm »
I have a somewhat large program (about 7,000 lines of code). I like to put a comment near the start of the program for each variable describing the purpose of the variable. However, I must admit that there are times where I've gone on extended code writing sprees and neglected to note each variable as I went along.

So here's the question: Is there any kind of trick that I can use to simply print out a list of all the variable names in use in my program?


Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
You're not done when it works, you're done when it's right.

Marked as best answer by hanness on February 16, 2020, 03:00:19 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Is there a way to get a list of all variables in a program?
« Reply #2 on: February 16, 2020, 12:41:47 am »
Use OPTION _EXPLICIT but you probably don't want to start with 7000 lines already coded.

But O_E forces you to DIM everything at which time you can do your commenting. It will even red line everything not DIM'd until you have every one listed. It must be first line in program and when you get tired of it's restrictive nature comment it out and play catch up later by removing comment when code is worked out or buggy. Bonus, saves you from typo bugs.
« Last Edit: February 16, 2020, 12:51:01 am by bplus »

Offline hanness

  • Forum Regular
  • Posts: 210
    • View Profile
Re: Is there a way to get a list of all variables in a program?
« Reply #3 on: February 16, 2020, 07:59:56 am »
Thank you both for 2 excellent solutions.