Recommended: Fault tolerance mechanism in ASP code Taking the most popular ASP in China as an example, I don’t know how many people think of the concept of fault tolerance when writing code. In fact, when I encounter such a thing, it is left unresolved. Why? Think about it, the original meaning was that you could tolerate mistakes by writing the following code. See Example 1-1
In ASP, you can call your own program through VBScript and other ways.
Example:
Calling a subroutine using VBScript
How to call a subroutine written in VBScript from ASP.
| The following is the quoted content: <html> <head> <% sub vbproc(num1,num2) response.write(num1*num2) end sub %> </head> <body> <p> You can call a procedure like this: </p> <p> Result: <l vbproc(3,4)%> </p> <p> Or, like this: </p> <p> Result: <%vbproc 3,4%> </p> </body> </html> Calling a subroutine using JavaScript How to call a subroutine written in JavaScript from ASP. <%@ language=javascript %> <html> <head> <% function jsproc(num1,num2) { Response.Write(num1*num2) } %> </head> <body> <p> Result: <%jsproc(3,4)%> </p> </body> </html> Call subroutines using VBScript and JavaScript How to call a subroutine written in VBScript and JavaScript in an ASP file. <html> <head> <% sub vbproc(num1,num2) Response.Write(num1*num2) end sub %> <script language=javascript runat=server> function jsproc(num1,num2) { Response.Write(num1*num2) } </script> </head> <body> <p>Result: <l vbproc(3,4)%></p> <p>Result: <l jsproc(3,4)%></p> </body> </html> Subprogram The ASP source code can contain subroutines and functions: <html> <head> <% sub vbproc(num1,num2) response.write(num1*num2) end sub %> </head> <body> <p>Result: <l vbproc(3,4)%></p> </body> </html> Write the line <%@ language=language %> to the <html> tag, and you can use another scripting language to write subroutines or functions: <%@ language=javascript %> <html> <head> <% function jsproc(num1,num2) { Response.Write(num1*num2) } %> </head> <body> <p>Result: <%jsproc(3,4)%></p> </body> </html> |
Differences between VBScript and JavaScript
When calling VBScript or JavaScript subroutines from an ASP file written in VBScript, you can use the keyword call, followed by the subroutine name. If the subroutine requires parameters, when using the keyword call, the parameters must be surrounded by brackets. If call is omitted, the parameters do not have to be surrounded by brackets. If the subroutine has no parameters, then brackets are optional.
When calling VBScript or JavaScript subroutine from an ASP file written in JavaScript, parentheses must be used after the subroutine name.
Share: Several common mistakes made by ASP beginners Several common mistakes made by ASP beginners 1. Open again before the record set is closed:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------