ASP 3.0 advanced programming)

Source: Internet
Author: User
7.1.2 semantic or "Runtime" error
The discovery and handling of syntax errors is annoying, but in programming, there will be another truly "exciting" type of errors-semantic errors) or runtime error ). This type of error is discovered only when a script code or other programs are run. In other words, the complete and valid code has been interpreted or compiled by the interpreter or compiler, resulting in an error during execution. The term "runtime errors" refers to semantic errors. That is to say, these errors exist in the semantics of the code and become visible only when the code is running.
This difference comes from the fact that the program compiler or interpreter must establish an internal code description before processing the program code, involving the matching of multiple structures at the beginning and end, to indicate what each structure contains, and then analyze each sentence to know how to execute the sentence. For example, If there is an If Then... Else... The first step of the End If structure, interpreter or compiler is to analyze which statements are in the "Then" section and which are in the "Else" section. The purpose of this step is to determine which branch to execute after testing the If condition in the structure.
Compilers (such as those seen in programming languages like Visual Basic and C ++) and Interpreters (such as interpreters for scripting languages like VBScript and JScript) the real difference between them is that the compiler runs the program code without testing the source program. After the source program is pre-processed twice, the code is a binary script or a symbol code, and is a. Exe file or. dll file. The interpreter does not contain files with code, but is executed gradually at runtime.
1. Error of stopping running
If the program contains a semantic error, a prompt is usually displayed at runtime. If you are lucky, the program stops when an error occurs, so that you can easily locate the error. For example, the following program defines an array with six elements.
<%
Dim arrValues (5) 'to hold six elements, indexed from 0 to 5
ArrValues (6) = "Whoops, got an error"
%>
If you try to read or set the element value with the subscript of 6, you can get a runtime error, as shown in Figure 7-7:
Figure 7-7 program execution result 6
Note that the error type here is "runtime" (equivalent to semantics) error, rather than syntax error. The error information displays the number of lines and descriptions of the error, which helps us easily find the corresponding error. However, this is a simple example. In more complex program code, such errors may occur when some values are traversed and added to an array program. As follows:
<%
Dim arrValues (5) 'to hold six elements
For intLoop = 0 To intListCount 'The number of items in some list
ArrValues (intLoop) = Request. Form ("SelectedItems") (intListCount)

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.