I have written a (Liberty basic) program designed to catch at least most errors of spelling or caSE in variable names, called Liberty Pre Pass (LPP). Liberty Basic (LB) assumes that all non identical variable names belong to different variables. So if there is a spelling mistake, LB assumes a new variable has been introduced – in effect has been implicitly declared. This can easily cause obscure bugs – as the author knows from experience. LPP introduces an explicit variable declaration mechanism that is transparent to LB. Based on this LPP scans your code and produces a list of undeclared variables. It also produces lists of ‘multiple declarations’, ‘unused declarations’, ‘all declarations’, and ‘all variables’
The attachment contains a Manual and the .bas file
No, LBPP is intended to provide functions not already available. But if you use a spelling not declared, it will be flagged by LBPP as an error.
Note that LBPP allows for declarations that are clearly different for globals vs declaration and use inside a function or subroutine.So declaring the variable "Var" in two different functions is ok acording to LBPP, and using Var in one and var in the other is also ok, because LBPP identifies the separate scopes - as long as each variable is declared inside its intended scope.
Last Edit: Jul 18, 2019 23:10:15 GMT -5 by petermat
tsh73, Thanks for the feedback! Took me a while to click in here. The bulk of the work on LBPP was done about two years ago, and then shelved for higher priorities. Just recently I picked it up and put in a couple of simple enhancements I had noted as needed doing, and sent it here. What I had not recorded was that I had an unanswered question in my mind. As it is LBPP records as "Variables" all the things you would expect, plus Function names - reasonable as they can be assigned to - and Subroutine names - which one does not expect. However a Subroutine name that is never called is just as interesting as a a variable declared and not used. I seemed to have two choices. One was to create a separate output that listed unused subroutine declarations (and possibly unused functions) and eliminate these from the Used and Unused variables lists. This would take more time than I had available then. The alternative was to re-label the "Unused variables" output as "Unused Variables and Funsubs". I meant to do the later pending finding whether anyone else cared about this whole idea, but forgot to document this decision. This renaming I have now done with the attached. Pre-Pass 211.zip (60.21 KB)
So it's not a bug - it's a (badly named) feature!
Lots of voices crying "I really need this, but only if the unused funsubs are separated from conventional variables" could cause me to find the time to separate out these aspects!
Last Edit: Jul 23, 2019 22:48:40 GMT -5 by petermat: New thoughts