Thanks for that info, Doug. If you get a chance, can you include the name of the function in the report?
Jamal On Wed, 10 Sep 2008, Doug Lee wrote: > Date: Wed, 10 Sep 2008 16:17:14 -0400 > From: Doug Lee <[EMAIL PROTECTED]> > Reply-To: [email protected] > To: [email protected] > Subject: An urging regarding error handling in Window-Eyes scripts > > I was prompted to put this message together by today's chain of > messages about various scripts that produce no output and/or seem to > stall forever. > > I've probably said this before, but I'm not sure if I said it here on > this list. > > I would like to urge Window-Eyes scripters that use VBScript to avoid > using "on error resume next" except where there is very good reason to > do so. Here are a few major problems that little command can cause: > > 1. If an error occurs in an If statement while an "on error resume > next" is in effect, it will always act True, because "resume next" > means resume execution inside the If part. This is usually exactly > what you do not want. > > 2. If an error occurs in a While or other loop condition, it can > cause an infinite loop, because "resume next" means resume execution > inside the loop. > > 3. You may put an "on error resume next" line in your code to catch > one type of error, but it will quietly absorb (and mask) any > unexpected type of error imaginable. For example, if you try > protecting yourself from division by 0 when calculating an average, > but you happen to misspell a variable name, you will get the wrong > answer without seeing why. > > When you do use "on error resume next," I recommend the following > precautions: > > 1. Run without that line first and make sure to figure out what kinds > of errors might occur there. This is the time to make sure nothing is > misspelled etc. > > 2. When you put the "on error resume next" line in, put a corresponding > "on error goto 0" line below it, and as close to the "on error > resume next" as possible. Avoid control flow commands like If, > While, sub and function calls, etc. within that little space between > the two lines. Think of the gap between "on error resume next" and > "on error goto 0" as a 500-foot deep crack in the ground: If you > don't want someone to fall in, keep that thing skinny! > > In case it's useful, I am pasting below the output of a > hastily-written Perl program that attempts to score vbs files on their > use of "on error resume next." Here are the rules it uses first: > > - A score of N means a set of N code lines between "on error resume > next" and "on error goto 0" (not inclusive) was found. > - Comments and blank lines in code don't count. > - A file's score is the highest count found in it. > - A sub, function, or file with an "on error resume next" that is not > turned back off gets an infinite score. > - Infinite scores will be suffixed with "function," "sub," or "file" to > indicate which type of infinity was found. > > I wrote this rather quickly, so pardon any errors in its results. I > did spot-check it though. > > And here's the output, most unprotected lines first, infinite scores > at the top, files scoring 0 omitted entirely. The file names are the > package name, a slash, and the actual file name. > > Infinite (Function): weatherornot/weatherornot.vbs > Infinite (Function): LookupTerm/LookupTerm.vbs > Infinite (Function): HomerSharedObject/HomerSharedObject.vbs > Infinite (Function): ExamineSystem/ExamineSystem.vbs > Infinite (Function): ActivateWindow/ActivateWindow.vbs > 81: progressindicator/ProgressIndicator.vbs > 59: HarvestWindow/HarvestWindow.vbs > 47: CaptureScreen/CaptureScreen.vbs > 46: weevent/weevent.vbs > 38: OperateServices/OperateServices.vbs > 34: CalculateDate/CalculateDate.vbs > 26: IEMax/IEMax.vbs > 20: winamp/winamp.vbs > 19: TerminateProcesses/TerminateProcesses.vbs > 18: RelaunchWindow-eyes/RelaunchWindow-eyes.vbs > 18: CheckLanguage/CheckLanguage.vbs > 16: TrackTime/TrackTime.vbs > 16: SetCheckbox/SetCheckbox.vbs > 16: SelectText/SelectText.vbs > 16: RunAtCursor/RunAtCursor.vbs > 16: RecentPaths/RecentPaths.vbs > 16: PasteSpecialCharacter/PasteSpecialCharacter.vbs > 16: JumpToItem/JumpToItem.vbs > 16: InteractiveJScript/InteractiveJScript.vbs > 16: InstallPackages/InstallPackages.vbs > 16: GoToSpecialFolder/GoToSpecialFolder.vbs > 16: GoToFolder/GoToFolder.vbs > 16: FocusControl/FocusControl.vbs > 16: EvaluateJScript/EvaluateJScript.vbs > 16: DetectShortcutKeys/DetectShortcutKeys.vbs > 16: AppendToClipboard/AppendToClipboard.vbs > 15: gwtoolkit/gwtoolkit.vbs > 15: MicrosoftWordCount/WinwordCount.vbs > 14: autocomplete/autocomplete.vbs > 11: HomerLayout/HomerLayout.vbs > 9: ScriptTemplate/ScriptTemplate.vbs > 9: ReplyToSender/ReplyToSender.vbs > 9: RemapCapsLock/RemapCapsLock.vbs > 9: EdSharp/EdSharp.vbs > 8: WEActions/WEActions.vbs > 8: TogglePunctuation/TogglePunctuation.vbs > 8: SpellIt/SpellIt.vbs > 8: ScriptMenu/ScriptMenu.vbs > 8: ScriptManager/ScriptManager.vbs > 8: RestoreDefaultSets/RestoreDefaultSets.vbs > 8: LearnScripting/LearnScripting.vbs > 8: KillWineyes/KillWineyes.vbs > 8: FileDir/FileDir.vbs > 8: DeleteStrokes/DeleteStrokes.vbs > 8: BeautifyVBScript/BeautifyVBScript.vbs > 6: easycddaextractor/easycddaextractor.vbs > 5: ShutdownNow/ShutdownNow.vbs > 5: RestartNow/RestartNow.vbs > 5: QuerySettings/QuerySettings.vbs > 5: LoadedScripts/LoadedScripts.vbs > 5: ConvertUnits/ConvertUnits.vbs > 4: AlternateMenu/AlternateMenu.vbs > 3: RelaunchWindow-eyes/BootStrap.vbs > > -- > Doug Lee, Senior Accessibility Programmer > SSB BART Group - Accessibility-on-Demand > mailto:[EMAIL PROTECTED] http://www.ssbbartgroup.com > "While they were saying among themselves it cannot be done, > it was done." --Helen Keller >
