|
Post by petermat on Jul 18, 2019 19:53:17 GMT -5
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 Attachments:Pre-Pass 210.zip (60.39 KB)
|
|
|
Post by alincon on Jul 18, 2019 20:35:47 GMT -5
LB does produce a list of 'similar' variables at compile time. Does your program do that, too?
r.m.
|
|
|
Post by petermat on Jul 18, 2019 20:54:55 GMT -5
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.
|
|
|
Post by Rod on Jul 19, 2019 2:18:22 GMT -5
Very cool utility. Interesting to see what it turns up on some of my larger programs.
|
|
|
Post by tsh73 on Jul 19, 2019 3:52:28 GMT -5
Hello petermat I run it on one of my programs
In VariablesUsed:
adjustWindowSize, is Outside all FunSub, Global, Used, 1, times - eg in line, 31, Declared
source line 31 is
call adjustWindowSize WindowWidth, WindowHeight
in GoodDeclarations
adjustWindowSize, is a Subroutine, -, is Used, and is Declared in line, 237, -
- should it not say adjustWindowSize is a sub or not list it in VariablesUsed?
|
|
|
Post by petermat on Jul 19, 2019 10:28:14 GMT -5
tsh73, I think you are correct, and I think I know why - but off out today - will look at this soon. Thanks for the feedback!
|
|
|
Post by petermat on Jul 19, 2019 22:24:26 GMT -5
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!
|
|