473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

Dec 31 '06 #1
2 2260
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:uc**************@TK2MSFTNGP02.phx.gbl...
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/
----------------------------------------

Dec 31 '06 #2
Bob Lehmann wrote:
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/
----------------------------------------

Jan 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python suppose you want to walk into a directory, say, to apply a string replacement to all html files. The os.path.walk() rises for the occasion. © import os ©...
12
OOP
by: demon_slayer2839 | last post by:
Hey yall, I'm new to Python and I love it. Now I can get most of the topics covered with the Python tutorials I've read but the one thats just stumping me is Object Orientation. I can't get the...
4
by: Newbee Adam | last post by:
will an application created in .NET run a windows 98 and 2000 machines -- Adam S
5
by: rip_tide | last post by:
I am trying to find out if C# has the ability to tie into windows so that when a user tries to save a file from any windows application a save as dialog box opens that is written in c# with other...
2
by: Chris Wood | last post by:
In C#, I am calling a method implemented in Managed C++ that returns an array of booleans. This method in turn calls unto unmanaged C++ code that returns an unsigned byte array, which is...
1
by: Manolatos Tilemahos | last post by:
Dear friends, First pls accept my apologies, because I am a new Postgres user, so my questions could be silly. We need to setup a database using UTF-8 encoding, however, by some way, we have...
4
by: peter | last post by:
In the sample northwind database when an order is sent the sent value come of the instock value. I can not work out how they have done this . I can see that it is an eventprocedure but can not...
8
by: ramu | last post by:
Hi, I want to call a vc++ function from a c program on linux. So when I do this dosen't the VC++ datatypes differ with c datatypes. Because we don't have some vc++ data types in c. I have to...
6
by: SpeedMath | last post by:
Actually, I already "compute out my wind vectors" in my case study by using Python. I couldn't find any information for plotting my wind vector field by using Python command.I...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.