home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 September
/
PCWorld_2000-09_cd.bin
/
Software
/
Topware
/
aspedit
/
_SETUP.1
/
counter4.asp
< prev
next >
Wrap
Text File
|
1998-07-02
|
1KB
|
46 lines
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
' Constants for FileSystemObject
Const ForReading = 1, ForWriting = 2
' Get the physical path of the counter file. The counter file is in the root of the
' web site.
sPath = Server.mapPath("/counter.txt")
' Lock the application
Application.Lock
' Create a file system object and open the count file for reading
Set fs = CreateObject ("Scripting.FileSystemObject")
Set CountFile = fs.OpenTextFile(sPath, ForReading)
' Read the first line of the count file, trim any spaces
sVisits = Trim(CountFile.Readline())
' Close the counter file
CountFile.Close
' Increment the count by 1
lVisits = CLng(sVisits) + 1
' Optional: Set this count in an Application variable
Application("Visits") = lVisits
' Open the count file for writing
Set CountFile = fs.OpenTextFile(sPath, ForWriting)
' Write the new count
CountFile.Writeline(lVisits)
' Close the counter file
CountFile.Close
' Unlock the application object
Application.Unlock
' Release File system object and counter file
Set Fs = Nothing
Set CountFile = Nothing
End Sub
</SCRIPT>