Javascript/vbscript script Debugging (wscript) _ Related skills

Source: Internet
Author: User
In practice, I find that programmers complain most about scripting that it is difficult to debug this shortcoming, especially when debugging. VBS and other WSH programs, always:
1. In the Resource Manager, double-click A. vbs file.
2. An error occurred in the program, such as an exception, or a programming logic error.
3. Read the source file in one line, then add a lot of msgbox.show and print the values of some variables where the error is estimated to occur.
4. Re-executing the. vbs file
5. "When", a series of "OK" after the point is over, people are dizzy, back to the third step to continue ...
In fact, we can also debug such WSH programs with Visual Studio, and the key is to provide debugging support for the interpreter Wscript.exe and cscript.exe of WSH scripts such as. vbs:
1. When we double-click a. vbs file in the Explorer, the resource manager actually runs wscript.exe to interpret and execute the. vbs file.
2. Both Wscript.exe and Cscript.exe support both options/d– enable debugging,/x– execute the script in the debugger.
So, there are two ways to debug a script in Visual Studio, and I'll just introduce the second method--the first method doesn't know why my win 7 + Visual Studio 2008 doesn't work,:(.
For example, the following. vbs code, save it to C: "Test.vbs, we want to debug this program, the source file is as follows:
Copy Code code as follows:

Set obj = CreateObject ("System.Collections.ArrayList")
Obj. ADD ("This is a test")
Obj. ADD (1)
Obj. ADD (obj)
Msgbox obj (0)
Msgbox obj (1)
Msgbox obj (2). ToString ()

1. Open the command line, replace the directory to C: Disk, execute the following command:
wscript.exe/x Test.vbs
2. This time, you should pop up a Visual Studio dialog box that prompts you to select the appropriate debugger and click on the OK button above.
3. Finally, you can set breakpoints in Visual Studio, like debugging C # or C + + programs, to view the values of variables, as shown in the following illustration:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.