Previous PageNext Page

10.4.1 Method Details

10.4.1.1 Get

The Get method takes the name of a counter and returns the current value of the counter. If the counter doesn't exist, the method creates it and sets it to 0.
 

    Arguments

        CounterName

        A string containing the name of the counter

    Example:

      Display the value a counter with <%= Counters.Get(CounterName) %>. Assign the value of the counter to a variable with <% countervar = Counters.Get(CounterName) %>.
      The following script displays the vote tally from a poll about favorite colors.
      <%
      If colornumber = "1" Then
      Counters.Increment("greencounter")
      Else
      If colornumber = "2" Then
      Counters.Increment("bluecounter")
      Else
      If colornumber = "0" Then
      Counters.Increment("redcounter")
      End If
      End If
      End If
      %>
      <P>Current vote tally:
      <P>red: <% =Counters.Get("redcounter") %>
      <P>green: <% = Counters.Get("greencounter") %>
      <P>blue: <% = Counters.Get("bluecounter") %>

10.4.1.2 Increment

The Increment method takes the name of a counter, adds 1 to the current value of the counter, and returns the counter's new value. If the counter doesn't exist, the method creates it and sets its value to 1.
 

    Arguments

        CounterName

        A string containing the name of the counter

    Example:

      Increment the value of a counter with <% Counters.Increment(CounterName) %>. Increment and display the value of a counter with <%= Counters.Increment(CounterName) %>.

      To retrieve the value of a counter, use Counters.Get. To set a counter to a specific value, use Counters.Set.

      The following code implements a one-line page-hit counter.

      <P>There have been <%= Counters.Increment("hits") %> visits to this Web page. </P>

      In this example, Counters.Increment increases the counter by one each time the client requests the page from the server.

10.4.1.3 Remove

The Remove method takes the name of a counter, removes the counter from the Counters object, and deletes the counter from the Counters.txt file.
 

    Arguments

        CounterName

        A string containing the name of the counter

    Example:

      The following code removes the counter hitscounter from the counters.txt file.

      <% Counters.Remove(hitscounter) %>

10.4.1.4 Set

The Set method takes the name of a counter and an integer, sets the counter to the value of the integer, and returns the new value. If the counter doesn't exist, Counters.Set creates it and sets it to the value of the integer.
 

    Arguments

        CounterName

        A string containing the name of the counter

        int

        The new integer value for CounterName

    Example:

      The following code resets the hit counter pageHits to 0:

      <% Counters.Set(pageHits, 0) %>


Copyright © 2000 Chili!Soft

Previous PageTop Of PageNext Page