Recommended: Tutorial for interpreting the asp call subroutine ASP programs can call subroutines through VBScript and other ways. Call a subroutine using VBScript, sample code: html head %subvbproc(num1,num2) response.write(num1*num2) endsub % /head body p You can call a program like this: /pp result: %callvbproc(3,4)%/pp or, like this: /pp result
Does the specified drive exist? This example demonstrates how to use the DriveExists method to detect whether a drive exists.The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) iffs.driveexists(c:)=truethen Response.Write(Drive c: exists.) Else Response.Write(Drive c: does not exist.) EndIf Response.write(<br>) iffs.driveexists(g:)=truethen Response.Write(Drive g: exists.) Else Response.Write(Drive g: does not exist.) EndIf setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
Drive c: exists.
Drive g: exists.
Get the name of a specified drive
This example shows how to use the GetDriveName method to get the name of a specified drive.
The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) p=fs.GetDriveName(c:/windows/cursors/abc.cur) Response.Write (drive name is: &p) setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
The drive name is: c:
Does the specified file exist?
This example demonstrates how to first create a FileSystemObject object, and then use the FileExists method to detect whether a file exists.
The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) If(fs.FileExists(c:/windows/cursors/xxx.cur))=trueThen Response.Write (File c:/windows/cursors/xxx.cur exists.) Else Response.Write(File c:/windows/cursors/xxx.cur does not exist.) EndIf setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
The file c:/windows/cursors/xxx.cur does not exist.
Does the specified folder exist?
This example demonstrates how to use the FolderExists method to detect whether a folder exists.
The code for this example is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Ifffs.FolderExists(c:/temp)=trueThen Response.Write(Folder c:/temp exists.) Else Response.Write(Folder c:/temp does not exist.) EndIf setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
The folder c:/temp does not exist.
Get the name of the parent folder of a specified path
This example shows how to use the GetParentFolderName method to get the name of the parent folder of a specified path.
The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) p=fs.GetParentFolderName(c:/winnt/cursors/3dgarro.cur) Response.Write(c:/windows/cursors/abc.cur's parent folder name is: &p) setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
The parent folder name of c:/winnt/cursors/abc.cur is: c:/winnt/cursors
Get the folder extension
This example shows how to use the GetExtensionName method to get the file extension of the last component in the specified path.
The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Response.Write (the file extension of file 3dgarro is:) Response.Write(fs.GetExtensionName(c:/windows/cursors/abc.cur)) setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
The file extension of file 3dgarro is: cur
Obtain file name
This example shows how to use the GetFileName method to get the file name of the last component in the specified path.
The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Response.Write (The last component of this file name is:) Response.Write(fs.GetFileName(c:/windows/cursors/abc.cur)) setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
The last ingredient of this file name is: abc.cur
Get the base name of the file or folder
This example shows how to use the GetBaseName method to return the base name of a file or folder in the specified path.
The code is as follows:
| <html> <body> <% Setfs=Server.CreateObject(Scripting.FileSystemObject) Response.Write(fs.GetBaseName(c:/windows/cursors/abc.cur)) Response.Write(<br/>) Response.Write(fs.GetBaseName(c:/windows/cursors/)) Response.Write(<br/>) Response.Write(fs.GetBaseName(c:/windows/)) setfs=nothing %> </body> </html> |
The operation results of this example are as follows:
| abc Cursors Windows |
Share: Analyzing the data addition and subtraction calculation method for ASP date format In ASP, we provide special date addition and subtraction functions. 1. DateAdd function returns the date where the specified time interval has been added. DateAdd(interval,number,date) The syntax of the DateAdd function has the following parameters (1) interval required. A string expression that indicates the time interval to be added. For values, see the Settings section.