Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 31st, 2006, 03:35 AM
Trevor L.
Guest
 
Posts: n/a
Default Whistling in the wind

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/
----------------------------------------

  #2  
Old December 31st, 2006, 05:05 PM
Bob Lehmann
Guest
 
Posts: n/a
Default Re: Whistling in the wind

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." <Trevor_L.@Canberrawrote in message
news:uc2THrILHHA.3668@TK2MSFTNGP02.phx.gbl...
Quote:
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
Quote:
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"))
Quote:
>
'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
Quote:
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"
Quote:
/><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/
----------------------------------------
>

  #3  
Old January 1st, 2007, 04:15 AM
Trevor L.
Guest
 
Posts: n/a
Default Re: Whistling in the wind

Bob Lehmann wrote:
Quote:
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/
----------------------------------------

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles