Whistling in the wind

Whistling in the wind

am 31.12.2006 04:21:04 von Trevor_L.

This is a multi-part message in MIME format.

------=_NextPart_000_1C37_01C72CE6.E7BEF460
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

The subject says it, I think.

I have a hit counter on my page below
The code is
Hit Counter:
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(" 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

Guestbook />

Guestbook


Even clicking Home increments it by 2
The Home button is

Home

Home


Visiting my other web site and then returning does the same thing
(increments it by 2).
This button is

T&C

Trevor and Carole's
Home Page


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

------=_NextPart_000_1C37_01C72CE6.E7BEF460
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">




The subject says it, I =
think.

 

I have a hit counter on my page =
below

The code is

<b>Hit Counter: =
</b><!--#include=20
file=3D'_fpclass/hit_count.inc'-->
where '_fpclass/hit_count.inc'=20
is

 

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

 

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

 

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

 

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

 

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

 

'Increment the visitor counter number =
by=20
1
lngVisitorNumber =3D lngVisitorNumber + 1

 

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

 

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

 

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

 

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

 

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

 

What I am wondering is:

Why does the count increment by 3 every =
time I=20
visit the Guestbook and then return to the Home Page ?


The Guestbook button =
is

<a href=3D"guestbook.asp" target=3D"_self">
  =
 <img=20
src=3D"images/display/guestbook-icon1.gif" alt=3D"Guestbook" =
height=3D"40" /><br=20
/>
   Guestbook</a>

 

Even clicking Home increments it =
by=20
2

The Home button is

<a href=3D"index.asp" =
target=3D"_self">
 =20
 <img src=3D"images/display/sitehome.gif" alt=3D"Home" =
/><br=20
/>
   Home</a>

 

Visiting my other web site and then =
returning does=20
the same thing (increments it by 2).

This button is

<a href=3D" href=3D"http://tandcl.homemail.com.au">http://tandcl.homemai l.com.au"=
>
 =20
 <img src=3D"images/display/trevor-and-carole.gif" =
alt=3D"T&C"=20
/><br />
   Trevor and Carole's<br />Home=20
Page</a>

Is there some way I can only increment =
the counter=20
when the site ( href=3D"http://trevorl.mvps.org/">http://trevorl.mvps.org/) is =
visited for the=20
first time?

And going to somewhere else and =
then returning=20
will not increment it?


--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage =
]
MVPS=20
Website: href=3D"http://trevorl.mvps.org/">http://trevorl.mvps.org/
-------=
---------------------------------


------=_NextPart_000_1C37_01C72CE6.E7BEF460--

Re: Whistling in the wind

am 31.12.2006 17:54:24 von 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." wrote in message
news:uc2THrILHHA.3668@TK2MSFTNGP02.phx.gbl...
> The subject says it, I think.
>
> I have a hit counter on my page below
> The code is
> Hit Counter:
> 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(" > 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
>
> Guestbook height="40"
> />

> Guestbook

>
> Even clicking Home increments it by 2
> The Home button is
>
> Home

> Home

>
> Visiting my other web site and then returning does the same thing
> (increments it by 2).
> This button is
>
> T&C

> Trevor and Carole's
Home Page

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

Re: Whistling in the wind

am 01.01.2007 05:07:24 von Trevor_L.

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" Hit Counter:

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