aspclassiccompiler/aspclassiccompiler/DLRSoft.Examples.ASPWebApp/components/Counters/Docs/Counter1.Htm
2020-04-14 14:05:42 +02:00

143 lines
4.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252">
<title>Counters Component</title>
<script language="JavaScript">
szNavVersion = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer") {
if (szNavVersion.indexOf ("4.") >= 0) {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie4.css">');
} else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie3.css">');
}
}
else if (navigator.appName == "Netscape") {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie4.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/spidie3.css">');
}
</script>
<meta NAME="DESCRIPTION" CONTENT="Internet Information Server reference information">
</head>
<body BGCOLOR="#FFFFFF" TEXT="#000000">
<font face="Verdana, Arial, Helvetica">
<h1><a name="_counters_component"></a>Counters Component</h1>
<p>The Counter component creates a <b>Counters </b>object that can create, store,
increment, and retrieve any number of individual counters. </p>
<p>A counter is a persistent value that contains an integer. You can manipulate a counter
with the <b>Get</b>, <b>Increment</b>, <b>Set</b>, and <b>Remove </b>methods of the <b>Counters
</b>object. Once you create the counter, it persists until you remove it.</p>
<p>Counters do not automatically increment on an event like a page hit. You must manually
set or increment counters using the <a href="counter5.htm"><b>Set</b></a> and <a
href="counter3.htm"><b>Increment</b></a> methods.</p>
<p>Counters are not limited in scope. Once you create a counter, any page on your site can
retrieve or manipulate its value. For example, if you increment and display a counter
named <i>hits</i> in a page called Page1.asp, and you increment <i>hits</i> in another
page called Page2.asp, both pages will increment the same counter. If you hit Page1.asp,
and increment <i>hits</i> to 34, hitting Page2.asp will increment <i>hits</i> to 35. The
next time you hit Page1.asp, <i>hits</i> will increment to 36.</p>
<p>All counters are stored in a single text file, Counters.txt, which is located in the
same directory as the Counters<i>.</i>dll file. </p>
<h2>File Names</h2>
<table>
<tr valign="top">
<td>Counters.dll</td>
<td>The Counters component.</td>
</tr>
<tr valign="top">
<td>Counters.txt</td>
<td>The file that stores all individual counters on a site. Counters.txt is a UTF8-encoded
file. You can have any Unicode characters in a counter name. </td>
</tr>
</table>
<p><br>
</p>
<h2>Syntax</h2>
<p>Create the <b>Counters</b> object one time on your server by adding the following to
the Global.asa file:</p>
<pre><b>&lt;OBJECT
RUNAT=Server
SCOPE=Application
ID=Counter
PROGID=&quot;MSWC.Counters&quot;&gt;
&lt;/OBJECT&gt;</b></pre>
<h2>Registry Entries</h2>
<p>None.</p>
<h2>Remarks</h2>
<p>Only create one <b>Counters </b>object in your site. This single <b>Counters </b>object
can create any number of individual counters. </p>
<p><b>Note</b> For Personal Web Server on Windows 95, a Counters component has already
been specified in the Global.asa file in the default virtual directory. You can work with
the <b>Counters </b>object the component creates as if it were a built-in object by
calling <b>Counters.Get</b>, <b>Counters.Increment</b>, <b>Counters.Remove</b>, and <b>Counters.Set</b>. You should not create another instance of the <b>Counters </b>object. </p>
<h2>Methods </h2>
<table>
<tr valign="top">
<td><a href="counter2.htm"><b>Get</b></a> </td>
<td>Returns the value of the counter. </td>
</tr>
<tr valign="top">
<td><a href="counter3.htm"><b>Increment</b></a> </td>
<td>Increases the counter by 1.</td>
</tr>
<tr valign="top">
<td><a href="counter4.htm"><b>Remove</b></a> </td>
<td>Removes the counter from the Counters.txt file. </td>
</tr>
<tr valign="top">
<td><a href="counter5.htm"><b>Set</b></a> </td>
<td>Sets the value of the counter to a specific integer. </td>
</tr>
</table>
<p><br>
</p>
<h2>Example</h2>
<p>Create an instance of the <b>Counters </b>object in the Global.asa file with the ID
attribute set to <code>Counter</code>: </p>
<pre>&lt;OBJECT RUNAT=Server SCOPE=Application ID=Counter PROGID=&quot;MSWC.Counters&quot;&gt; &lt;/OBJECT&gt;
</pre>
<p>You can then use that <b>Counters </b>object on one page to create all the counters you
need:</p>
<pre>There have been &lt;%= Counter.Increment('defaultPageHits') %&gt; to this site.
</pre>
<p>Then on another page you can increment the counter in the following manner:</p>
<pre>You are visitor number&lt;%= Counter.Increment('LinksPageHits') %&gt; to this page.
</pre>
</font>
</body>
</html>