![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Turning on options explicit I've inherited a several thousand line vbs script. Options Explicit is commented out in it. I've found one mistyped variable and I'm sure there are more. Is there a way to uncomment it and do a syntax check on the code? So far I can just get it to point out undeclared variables when it hits them during execution. Brian |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Turning on options explicit BrianB wrote: Quote: > I've inherited a several thousand line vbs script. Options Explicit is > commented out in it. I've found one mistyped variable and I'm sure there are > more. Is there a way to uncomment it and do a syntax check on the code? So > far I can just get it to point out undeclared variables when it hits them > during execution. > > Brian > Even visual basic (classic) will let you type in anything, and not catch it until it executes. (Not experienced with vb.net). I have one suggestion, not easy, but with "thousands of lines of code", the extra effort may be worth it. Here goes: get yourself an programmer's editor with syntax highlighting, which allows for you to input the language syntax. (For example, scintilla, or EditPlus). It will most likely come with a vbs syntax file (or at least a visual basic syntax file). The syntax file will come with lists of language verbs (do, stop, etc), and will include instructions for "colorizing" various language elements (strings, constants). What I suggest is to set up another category, lets call it "declared variables". In this category you place all the variable names that are dimensioned (i.e., declared). You also set up your colorization rules to highlight the declared variables. This leaves the UN-colorized variables as un-declared (note that the language elements are generally colorized). This sounds like a sure way to get eye-strain, looking for un-colorized variables. But if you set the default color to something noticeable then that might make the un-declared variables stand out more. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) p.s. you might wish to first check with some of the "high priced" editors (like Sapien PrimalScript) to see if they will auto-magically detect any undeclared variables (without going into execution). |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Turning on options explicit In article <e2ng$AATJHA.4456@xxxxxx>, kindlyReplyToNewsgroup@xxxxxx says... Quote: > BrianB wrote: Quote: > > I've inherited a several thousand line vbs script. Options Explicit is > > commented out in it. I've found one mistyped variable and I'm sure there are > > more. Is there a way to uncomment it and do a syntax check on the code? So > > far I can just get it to point out undeclared variables when it hits them > > during execution. > > > > Brian > > > hi Brian, unfortunately, that's the way it works. > > Even visual basic (classic) will let you type in anything, > and not catch it until it executes. (Not experienced with > vb.net). classic will catch undeclared variables at compile time, rather than waiting until runtime. I wonder if importing his big vbscript into a VB IDE might compile well enough to catch the undeclared var's? ..... -- /~\ The ASCII \ / Ribbon Campaign X Against HTML / \ Email! Remove the ns_ from if replying by e-mail (but keep posts in the newsgroups if possible). |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Turning on options explicit "David Kerber" <ns_dkerber@xxxxxx_WarrenRogersAssociates.com> wrote in message news:MPG.2390cd92b60c033b989cce@xxxxxx Quote: > In article <e2ng$AATJHA.4456@xxxxxx>, > kindlyReplyToNewsgroup@xxxxxx says... Quote: >> BrianB wrote: Quote: >> > I've inherited a several thousand line vbs script. Options Explicit is >> > commented out in it. I've found one mistyped variable and I'm sure there >> > are >> > more. Is there a way to uncomment it and do a syntax check on the code? So >> > far I can just get it to point out undeclared variables when it hits them >> > during execution. >> > >> > Brian >> > >> hi Brian, unfortunately, that's the way it works. >> >> Even visual basic (classic) will let you type in anything, >> and not catch it until it executes. (Not experienced with >> vb.net). > If you set "Option Explicit" (which is not the default, AFAIK), VB > classic will catch undeclared variables at compile time, rather than > waiting until runtime. > > I wonder if importing his big vbscript into a VB IDE might compile well > enough to catch the undeclared var's? well.... Quote: > .... > > -- > /~\ The ASCII > \ / Ribbon Campaign > X Against HTML > / \ Email! > > Remove the ns_ from if replying by e-mail (but keep posts in the > newsgroups if possible). > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Turning on options explicit "MikeB" <m.byerleyATVerizonDottieNettie> wrote in message news:%23Z1n2GCTJHA.1160@xxxxxx Quote: > > "David Kerber" <ns_dkerber@xxxxxx_WarrenRogersAssociates.com> wrote in message > news:MPG.2390cd92b60c033b989cce@xxxxxx Quote: >> In article <e2ng$AATJHA.4456@xxxxxx>, >> kindlyReplyToNewsgroup@xxxxxx says... Quote: >>> BrianB wrote: >>> > I've inherited a several thousand line vbs script. Options Explicit is >>> > commented out in it. I've found one mistyped variable and I'm sure >>> > there are >>> > more. Is there a way to uncomment it and do a syntax check on the >>> > code? So >>> > far I can just get it to point out undeclared variables when it hits >>> > them >>> > during execution. >>> > >>> > Brian >>> > >>> >>> hi Brian, unfortunately, that's the way it works. >>> >>> Even visual basic (classic) will let you type in anything, >>> and not catch it until it executes. (Not experienced with >>> vb.net). >> If you set "Option Explicit" (which is not the default, AFAIK), VB >> classic will catch undeclared variables at compile time, rather than >> waiting until runtime. >> >> I wonder if importing his big vbscript into a VB IDE might compile well >> enough to catch the undeclared var's? > It's OK for VB6 for sure and I use VBA editor to prototype Scripts as > well.... > Quote: >> .... >> >> -- >> /~\ The ASCII >> \ / Ribbon Campaign >> X Against HTML >> / \ Email! >> >> Remove the ns_ from if replying by e-mail (but keep posts in the >> newsgroups if possible). >> Brian |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Turning on options explicit > Quote: > What I suggest is to set up another category, lets call it > "declared variables". In this category you place all > the variable names that are dimensioned (i.e., declared). > You also set up your colorization rules to highlight the > declared variables. This leaves the UN-colorized variables > as un-declared (note that the language elements are generally > colorized). > www.jsware.net/jsware/webed.php5 Colorizes declared variables automatically. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Turning on options explicit "ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message news:4927477e$0$30236$9b4e6d93@xxxxxx-online.net... Quote: > BrianB schrieb: Quote: >> I've inherited a several thousand line vbs script. Options Explicit is >> commented out in it. I've found one mistyped variable and I'm sure there >> are more. Is there a way to uncomment it and do a syntax check on the >> code? So far I can just get it to point out undeclared variables when it >> hits them during execution. >> >> Brian > names > (2) Static code analysis based on lists of allowed words (reserved > words, names of known Subs/Functions, names of Dim'ed variables) > is a lot of work and error-prone > (3) To gain confidence in the script, you'll have to test it anyway it, as well. mayayana suggested that the WEB-ED editor could help you differentiate between declared and undeclared variables. That might be of great help in the task. But if the missing declarations hide some logical error, I do not think you can expect a tool to automatically correct it. /Al |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Turning on options explicit Il giorno Mon, 24 Nov 2008 21:30:39 -0700, "Al Dunbar" <alandrub@xxxxxx> ha scritto: Quote: >mayayana suggested that the WEB-ED editor could help you differentiate >between declared and undeclared variables. That might be of great help in >the task. But if the missing declarations hide some logical error, I do not >think you can expect a tool to automatically correct it. cross reference of the variables and the lines where they were used. If a variable is used only once then there should be an error. Anyone willing to enjoy writing this for vbscript? -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) -- |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Turning on options explicit Quote: > I read (23 years ago) of a program for the Commodore 64 which parsed the Quote: > cross reference of the variables and the lines where they were used. > If a variable is used only once then there should be an error. > Anyone willing to enjoy writing this for vbscript? an elaborate tool. Just running it and checking error line numbers seems to work fine for me. Maybe others have a different way of doing things. For myself, I find that the *really* hard part is familiarizing myself with the code. For that, color syntax highlighting is very helpful, but I still have to work out the logic. Until I have the whole layout and functionality of a script clear in my mind -- whether it's my code or someone else's -- I can't do much of anything useful with it. |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Turning on options explicit "mayayana" <mayaXXyana@xxxxxx> wrote in message news:epS7vwjUJHA.1164@xxxxxx Quote: > Quote: >> I read (23 years ago) of a program for the Commodore 64 which parsed the Quote: >> cross reference of the variables and the lines where they were used. >> If a variable is used only once then there should be an error. simply knowing this will still require the scripter to determine the cause of the problem: was a variable name spelt incorrectly, for example? But this will only flag those errors where the incorrect spelling of one variable is *not* the same as the correct spelling of another - an error that is often more difficult to deal with. Another way this can happen is when chunks of code are deleted... There are so many other possible logic errors that cannot be found through mechanical means, that such a limited tool would not seem to me to be worth the cost to develop. But, all this said, having a single instance of one variable name may not always be an error. Consider that the variable might be defined in a script snippet instantiated in code generated dynamically with EXECUTEGLOBAL. Quote: Quote: >> Anyone willing to enjoy writing this for vbscript? > I've never seen or written a VBScript that needed such > an elaborate tool. Just running it and checking error line > numbers seems to work fine for me. Maybe others have a > different way of doing things. For myself, I find that the *really* > hard part is familiarizing myself with the code. For that, > color syntax highlighting is very helpful, but I still have to > work out the logic. Until I have the whole layout and > functionality of a script clear in my mind -- whether it's my > code or someone else's -- I can't do much of anything useful > with it. editor having intellisense capabilities, that is likely to prevent some errors up front, as it will be aware of the number and names of parameters in function calls, and possibly match code block elements. That, along with adopting a consistent approach to coding standards wil, I think, get one much farther along than any single-function code analysis tool will be able to. /Al |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Enabling ECN (Explicit Congestion Notification) in Vista | Vista networking & sharing | |||
| How do you Enable ECN (Explicit Congestion Notification) | Vista General | |||
| implicit/explicit data type conversion? | PowerShell | |||
| RE: Option Explicit | PowerShell | |||
| OPTION EXPLICIT | PowerShell | |||