How To: Varusage and variables only used in &if-statement

I'm trying out the ProParse/ProLint utilities and can't find a solution on how to deal with the following situation:
- use of Varusage to check on defined variables that are never used
- If there are variables that are only used in &if-blocks (and at the moment of the check this &if-statement gives a false result) I will get the message that this variable is defined but never used.
Now in this cases the next step I should do is to delete these unused variables but it is possible that the variable is used if the &if-statement give a positive result (so the variable has to be defined).

So my question is: how can I configure ProLint so that all &if-blocks are always processed (so actually I want ProLint to skip the &if/&elseif/... lines in the check - in that way I will be certain that I may delete the define variable when I get the message that a variable is defined and never used

NB: I'm very impressed of the capabilities/possibilities of ProLint and I intend to use this great tool for making our code as effective as possible!!
Thanks for developing such a useful tool!!!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
john's picture

Re: processing &IF blocks

Hi,

There aren't any configuration options in Proparse for ignoring &IF statements to force processing of all &if-blocks. Sorry. In most cases, if you ignored &IF statements, the resulting code would not parse or compile correctly - the syntax would not be valid. So, Proparse would not be able to build a valid syntax tree.

I'm glad you like Prolint, and I hope you continue to enjoy using it. I'm sure you'll find a reasonably easy way to get what you want from &IF and Varusage.


OK, but how can I be sure

OK, but how can I be sure that a variable that´s only been used in a &if-statement does't appear in the result list as 'never used' or 'assigned but never used' if the usage of that variable happens in the negative part of the &if-statement (the part that will not be executed in this run of prolint).


john's picture

Re: &IF and varusage

There is no easy way to do exactly what you are asking.

There are various general approaches to getting rid of Prolint warnings, but without being in your shoes it's a bit hard to advise.

One approach is to tweak Prolint. For example, add a filter (http://www.oehive.org/node/251) to watch for warnings where you know this situation exists.

Another approach is to change the code. For example, you might make sure that the DEFINE statement is surrounded by the same &IF condition as the variable's usages.

Is there an environment variable you could change before launching Prolint, so that the &IF evaluates to true, so that the variable usage is found? If there isn't an environment setting that would trigger the &IF to evaluate to true, then perhaps the variable really is never used.

Another approach of course is to enhance the Prolint rule itself. For this situation, I don't think this would be the best approach. This would be challenging, and I also wonder whether it would be found useful outside your own system's code.

If all of your &IF conditions evaluated to true, would your code compile?

I think that all code is dumped into COMPILE..LIST, even if it is surrounded by an &IF that evaluates to false (correct?). Perhaps you could search through that (using regular expressions) for usages of the variable.