Recommended: Deeply understand the magical features of FSO in ASP In ASP, FSO means File System Object, which is a file system object. The computer file system we are going to manipulate refers to being located on the web server. So, make sure you have the right permissions for this. Ideally, you can use your own machine
7.1.2 Semantic or runtime errorsThe discovery and handling of syntax errors is annoying, but you will encounter some really exciting other type of error in programming - semantic errors or runtime errors. This type of error is only discovered when running a script code or other program. In other words, complete and valid code has been interpreted or compiled by the interpreter or compiler, and an error occurred during execution. The term run-time error pass refers to the result of semantic errors, that is, such errors exist in the semantics of the code and become visible when the code is run.
This difference comes from the fact that a program compiler or interpreter must establish a description of internal code before handling the program code, involving the match of the beginning and end of multiple structures in order to indicate what each structure contains, and then analyze each sentence in order to know how to execute the sentence. For example, if there is an If Then … Else … End If structure, the first step of the interpreter or compiler is to analyze which statements are in the Then part and which are in the Else part. The purpose of this step is to determine which branch to execute after testing the If conditions in the structure.
The real difference between a compiler (such as the one seen in programming languages like Visual Basic and C) and an interpreter (such as the interpreter for scripting languages like VBScript and JScript) is that the compiler does not try to run program code, but after two preprocessing of the source program, it forms binary instructions or symbolic code and forms a .exe file or .dll file. The interpreter does not contain a file of code, but is executed step by step at runtime.
1. Error causing the run to stop
If the program contains a semantic error, you can usually get a prompt at runtime. If you are lucky, the program will stop when an error occurs, so that it is easy to find out where the error is. 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 to 6, you can get a run-time error, as shown in Figure 7-7:
Figure 7-7 Program execution result 6
Note that the error type here is a runtime (equivalent to semantics) error, not a syntax error. The error message shows the number of rows where the error is located and the description of the error, which helps us find the corresponding error more easily. But this is a simple example, in more complex program code, this error may occur in some programs traversing some values and adding them to an array. As shown below:
<%
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)
Next
%>
In this case, it is likely that you have obtained too many list entries, or the index of the array is insufficient. According to the code requirements, you can determine which error it is, and you can solve this error by increasing the array size.
<%
Dim arrValues(10) ' to hold eleven elements
For intLoop = 0 To intListCount ' the number of items int some list
arrValues(intLoop) = Request.Form(SelectedItems)(intListCount)
Next
%>
Or set the loop parameters accordingly to resolve the error handling.
<%
Dim arrValues(5) ' to hold six elements
IntArrayMax = intListCount
If intArrayMax > 5 Then intArrayMax = 5
For intLoop = 0 To intArrayMax ' only add the first six items
arrValues(intLoop) = Request.Form(SelectedItems)(intListCount)
Next
%>
Many other runtime errors can stop web pages from running, such as instantiation of some components or objects, because there is a ProgID error or because the component is not installed correctly. In these cases, the result always gives the ActiveX Cannot Create Object error message, followed by the line number of the call to the Server.CreateObject method.
2. Error producing error results
As mentioned above, we may be lucky if we encounter a runtime error that causes the program code to stop. But another situation is that the program can execute well, as if nothing happened, and finally produces an incorrect result. This is the most difficult mistake to discover and solve because you are not aware of something wrong. For example, suppose there is a web page that takes the user's birthday as a date value and displays the date elements separately (you can add them as three entries to a database).
<%
' get the value from the Request and display it
datBirthdate = Request.Form(Birthdate)
Response.Write The value you entered is: & datBirthdate & <P>
' get the individual date elements
intDay = Day(datBirthdate)
intMonth = Month(datBirthdate)
intYear = Year(datBirthdate)
' and display them
Response.Write Day: & Cstr(intDay) & <BR>
Response.Write Month: & Cstr(intMonth) & <BR>
Response.Write Year: & Cstr(intYear) & <BR>
%>
Figure 7-8 is the result, displayed in the American date style month/day/year, as if everything is fine.
Figure 7-8 The screen showing birthday
However, if you enter an illegal date or leave the input text box empty, you will get a run-time error, as shown in Figure 7-9:
Figure 7-9 Error prompt screen
(1) If not a JScript expert
This is not a big problem when looking for errors, because we are able to quickly discover why the errors are occurring. The fact that the web page stops running helps us track errors. However, unexpected errors can occur. For example, rewriting program code in JScript, because I am not a JScript expert, some minor errors appear.
<%
// get the value from the Request and display it
var datBirthdate = new Date(Request.Form(Birthdate));
Response.Write(The value you entered is: datBirthdate <P>);
// get the individual date elements
intDay = datBirthdate.getDay();
intMonth = datBirthdate.getMonth();
intYear = datBirthdate.getYear();
// and display them
Response.Write(Day: intDay.toString() <BR>);
Response.Write(Month: intMonth.toString() &
Share: Use ASP to implement the full operation strategy for MP3 track information Let’s briefly talk about the ID3 tag of MP3, because it is mainly used to operate this thing. MP3 was not what we saw today at the beginning. There are singers, eras, collections, etc. information, and only some simple parameters such as yes/no to indicate whether it is private or copyrighted.