Skip to content

Instantly share code, notes, and snippets.

@artlung
Created November 2, 2009 20:32
Show Gist options
  • Save artlung/224439 to your computer and use it in GitHub Desktop.
Save artlung/224439 to your computer and use it in GitHub Desktop.
ASP Counter, vintage 2004
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
REM From joe@artlung.com Fri Jan 16 01:47:57 2004
REM Date: Thu, 15 Jan 2004 19:52:03 -0500 (EST)
REM From: Joe Crawford <joe@artlung.com>
REM To: Joe Crawford <joe@artlung.com>
REM Subject: ASP counter
REM include this file with
REM <script type="text/javascript" language="JavaScript" src="js-counter.asp"></script>
dim fs, a, Wfile
Set fs = CreateObject("Scripting.FileSystemObject")
Wfile=Server.MapPath("\counters") & "\counterfile.txt"
on error resume next
Set a = fs.OpenTextFile(Wfile)
hits = Clng(a.ReadLine)
hits = hits + 1
a.close
if error then
hits = 1
end if
Set a = fs.CreateTextFile(Wfile,True,False)
a.WriteLine(hits)
a.Close
a = nothing
Wfile = nothing
Response.ContentType = "application/x-javascript"
%>
var x='<% =hits %>';
var threeCount=0;
var outString = '';
for(i=x.length-1;i>=0;i--) {
outString=(x.charAt(i))+outString;
threeCount++;
if(threeCount==3 && i!=0){
outString=','+outString;
threeCount=0;
}
}
document.write(outString);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment