tailieunhanh - Microsoft WSH and VBScript Programming for the Absolute Beginner Part 32

Microsoft WSH and VBScript Programming for the Absolute Beginner by Jerry Lee Ford Part 32. If you are new to programming with Microsoft WSH and VBScript and are looking for a solid introduction, this is the book for you. Developed by computer science professors, books in the for the absolute beginner series teach the principles of programming through simple game creation. You will acquire the skills that you need for more practical WSH and VBScript programming applications and will learn how these skills can be put to use in real-world scenarios. Best of all, by the time you finish this book,. | Microsoft WSH and VBScript Programming for the Absolute Beginner Second Edition Figure 9-7 A custom error message generated by a VBScript error handler. The Err object also provides two very useful methods. One of these methods is the Clear method. This method clears out or removes the previous error ensuring that the next time a script checks for an error it will not get a false status that is it won t see an already handled error . To use the Clear method place it at the end of your error-handling routine as demonstrated in the previous example. VBScript automatically executes the Clear method on several occasions including Whenever the On Error Resume Next statement executes Whenever an Exit Sub statement executes Whenever an Exit Function statement executes The second Err object method is the Raise method. This method allows you to generate error messages to test your error-handling routines. Without this method the only way that you could test your error-handling routines would be to deliberately introduce an error situation into your code. This method is easy to use as demonstrated by the following 500 For example if you save the previous statement as a script and run it you will see the error message shown in Figure . To use the Raise method add it along with the error number indicating the error that you want to generate just before the error-handling procedure that you want to test in your script. After you have validated that the error handler is working as expected remove the Raise statement from your VBScript. jlGURE 9-8 Using the Err object s Raise method to generate a test error. Chapter 9 Handling Script Errors Reporting Errors The best solution for errors is to prevent them from occurring in the first place however that s not always possible. The next best solution is to devise a way of dealing with errors whether it be handling them or simply ignoring them. Another option is to report errors by recording them to a log file for later .

TÀI LIỆU MỚI ĐĂNG
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.