asp 가장 간단 하고 실 용적 인 카운터
2999 단어 asp 가장 간단 하고 실 용적 인 카운터
<%
option explicit
dim fs,filename,txt,content,total,counter_lenth
counter_lenth=1 ' ,
set fs=Server.CreateObject("Scripting.FileSystemObject")
filename=server.MapPath("count.txt")
if not fs.FileExists(filename) then
fs.CreateTextFile filename,True,True
set txt=fs.OpenTextFile(filename,2,true)
txt.write 0 ' 0
set fs=nothing
end if
set txt=fs.OpenTextFile(filename)
If txt.AtEndOfStream Then
Application("Counter")=0 ' , Application("Counter") ( )
else
Application("Counter")=txt.readline
end if
Application.Lock
Application("Counter") = Application("Counter") + 1
Application.UnLock
Function save_ '
set fs=Server.CreateObject("Scripting.FileSystemObject")
filename=server.MapPath("count.txt")
content=Application("Counter")
set txt=fs.OpenTextFile(filename,2,true)
txt.write content
set fs=nothing
End Function
save_ '
Function Digital ( counter ) '
Dim i,MyStr,sCounter
sCounter = CStr(counter)
For i = 1 To counter_lenth - Len(sCounter)
MyStr = MyStr & "0"
'MyStr = MyStr & "<IMG SRC= \0.gif>" ' ,
Next
For i = 1 To Len(sCounter)
MyStr = MyStr & Mid(sCounter, i, 1)
'MyStr = MyStr & "<IMG SRC= \" & Mid(sCounter, i, 1) & ".gif>" ' ,
Next
Digital = MyStr
End Function
Function count_show '
set fs=Server.CreateObject("Scripting.FileSystemObject")
filename=server.MapPath("count.txt")
set txt=fs.opentextfile(filename,1,true)
total=txt.readline
total=cint(total)
'response.write total
response.write Digital (total) '
set fs=nothing
End Function
%>
그리고 count.txt(count.asp 와 같은 레벨 디 렉 터 리 가 필요 합 니 다)를 새로 만 들 고 이 파일 을 열 고 그 안에 임의의 숫자(너무 독 하 게 하지 마 세 요)를 입력 한 다음 계수 기 를 표시 해 야 하 는 페이지 상단 에 가입
<!--#include file="count.asp"-->
하고 마지막 으로 계수 기 를 표시 해 야 하 는 곳 에 코드
<%=count_show%>
를 추가 하면 됩 니 다.