Whistling in the wind

T

Trevor L.

The subject says it, I think.

I have a hit counter on my page below
The code is
<b>Hit Counter: </b><!--#include file='_fpclass/hit_count.inc'-->
where '_fpclass/hit_count.inc' is

<%
'Dimension variables
Dim fsoObject 'File System Object
Dim filObject 'File Object
Dim tsObject 'Text Stream Object
Dim lngVisitorNumber 'Holds the visitor number
Dim intWriteDigitLoopCount 'Loop counter to display the graphical hit count
Dim cntDigit 'Holds the digit displayed in the counter

'Create a File System Object variable
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

'Initialise a File Object with the path and name of text file to open
Set filObject = fsoObject.GetFile(Server.MapPath("_private/index.asp.cnt"))

'Open the visitor counter text file
Set tsObject = filObject.OpenAsTextStream

'Read in the visitor number from the visitor counter file
lngVisitorNumber = CLng(tsObject.ReadAll)

'Increment the visitor counter number by 1
lngVisitorNumber = lngVisitorNumber + 1

'Create a new visitor counter text file over writing the previous one
Set tsObject =
fsoObject.CreateTextFile(Server.MapPath("_private/index.asp.cnt"))

'Write the new visitor number to the text file
tsObject.Write CStr(lngVisitorNumber)

'Reset server objects
Set fsoObject = Nothing
Set filObject = Nothing
Set tsObject = Nothing

'Display the hit count as text
' Response.Write(lngVisitorNumber)

'Loop to display graphical digits
For intWriteDigitLoopCount = 1 to Len(lngVisitorNumber)
' Display the graphical hit count
cntDigit = Mid(lngVisitorNumber, intWriteDigitLoopCount, 1)
Response.Write("<img src=""counter_images/")
Response.Write(cntDigit & ".gif""")
Response.Write(" alt=""" & cntDigit & """>")
Next
%>

What I am wondering is:
Why does the count increment by 3 every time I visit the Guestbook and then
return to the Home Page ?
The Guestbook button is
<a href="guestbook.asp" target="_self">
<img src="images/display/guestbook-icon1.gif" alt="Guestbook" height="40"
/><br />
Guestbook</a>

Even clicking Home increments it by 2
The Home button is
<a href="index.asp" target="_self">
<img src="images/display/sitehome.gif" alt="Home" /><br />
Home</a>

Visiting my other web site and then returning does the same thing
(increments it by 2).
This button is
<a href="http://tandcl.homemail.com.au">
<img src="images/display/trevor-and-carole.gif" alt="T&C" /><br />
Trevor and Carole's<br />Home Page</a>

Is there some way I can only increment the counter when the site
(http://trevorl.mvps.org/) is visited for the first time?
And going to somewhere else and then returning will not increment it?

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
 
B

Bob Lehmann

Put the code that increments the count in the Session_OnStart sub in
global.asa.

Also, you should look into using Application.Lock while writing to your text
file.

Bob Lehmann

Trevor L. said:
The subject says it, I think.

I have a hit counter on my page below
The code is
<b>Hit Counter: </b><!--#include file='_fpclass/hit_count.inc'-->
where '_fpclass/hit_count.inc' is

<%
'Dimension variables
Dim fsoObject 'File System Object
Dim filObject 'File Object
Dim tsObject 'Text Stream Object
Dim lngVisitorNumber 'Holds the visitor number
Dim intWriteDigitLoopCount 'Loop counter to display the graphical hit count
Dim cntDigit 'Holds the digit displayed in the counter

'Create a File System Object variable
Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

'Initialise a File Object with the path and name of text file to open
Set filObject = fsoObject.GetFile(Server.MapPath("_private/index.asp.cnt"))

'Open the visitor counter text file
Set tsObject = filObject.OpenAsTextStream

'Read in the visitor number from the visitor counter file
lngVisitorNumber = CLng(tsObject.ReadAll)

'Increment the visitor counter number by 1
lngVisitorNumber = lngVisitorNumber + 1

'Create a new visitor counter text file over writing the previous one
Set tsObject =
fsoObject.CreateTextFile(Server.MapPath("_private/index.asp.cnt"))

'Write the new visitor number to the text file
tsObject.Write CStr(lngVisitorNumber)

'Reset server objects
Set fsoObject = Nothing
Set filObject = Nothing
Set tsObject = Nothing

'Display the hit count as text
' Response.Write(lngVisitorNumber)

'Loop to display graphical digits
For intWriteDigitLoopCount = 1 to Len(lngVisitorNumber)
' Display the graphical hit count
cntDigit = Mid(lngVisitorNumber, intWriteDigitLoopCount, 1)
Response.Write("<img src=""counter_images/")
Response.Write(cntDigit & ".gif""")
Response.Write(" alt=""" & cntDigit & """>")
Next
%>

What I am wondering is:
Why does the count increment by 3 every time I visit the Guestbook and then
return to the Home Page ?
The Guestbook button is
<a href="guestbook.asp" target="_self">
<img src="images/display/guestbook-icon1.gif" alt="Guestbook" height="40"
/><br />
Guestbook</a>

Even clicking Home increments it by 2
The Home button is
<a href="index.asp" target="_self">
<img src="images/display/sitehome.gif" alt="Home" /><br />
Home</a>

Visiting my other web site and then returning does the same thing
(increments it by 2).
This button is
<a href="http://tandcl.homemail.com.au">
<img src="images/display/trevor-and-carole.gif" alt="T&C" /><br />
Trevor and Carole's<br />Home Page</a>

Is there some way I can only increment the counter when the site
(http://trevorl.mvps.org/) is visited for the first time?
And going to somewhere else and then returning will not increment it?

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
T

Trevor L.

Bob said:
Put the code that increments the count in the Session_OnStart sub in
global.asa.

Also, you should look into using Application.Lock while writing to
your text file.

Bob Lehmann

Thanks, Bob

This appears to have worked. However, I tried this once before and the next
time I went into the site, the Hit Counter wasn't even displaying.
(That is, if I recall correctly, this code" <b>Hit Counter:
</b><!--#include file='_fpclass/hit_count.inc'--><br /> didn't even display
*Hit Counter*

Maybe I did something wrong last time, so I think I will wait for the time
out period (15 minutes ?) and try again with my fingers crossed

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top