Web Design Forum: Formatting simple counter - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Formatting simple counter Rate Topic: -----

#1 User is offline   high1 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 15-March 10
  • Reputation: 0

Posted 16 March 2010 - 09:50 AM

Hello

I have a simple ASP counter script which digits in text format:

<%@ Language = VBSCRIPT %>
<% Option Explicit %>
<% 
' Variable Section
    Const ForReading = 1
    Const ForWriting = 2
    Const UseText = 0 		' Use this constant if you want to use text for the counter display
    Const UseImages = 1		' Use this constant if you want to use images for the counter display
    Dim objCounterFile, objFSO, strFilePath, strImageName, displayOption, imageDirectory
    Dim strCounterNumber, iCounterNumber, strCurrentIP, strLastIP

' Set this equal either to 0 or 1, make it equal either UseImages of UseText
' depending on which you want to use to show your counter.

    displayOption = 0		

' Set this string equal to the sub-directories that you follow to your images directory
' This is from the directory that contains the file that executes "counter.asp"

    imageDirectory = "images/"		

'
' Gathering information
    strCurrentIP = Request.ServerVariables("REMOTE_ADDR")
    strFilePath = Server.MapPath("counter.txt")
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'
' Checking for the file counter.txt
    If (objFSO.FileExists(strFilePath)) then
      Set objCounterFile = objFSO.OpenTextFile(strFilePath, ForReading)
' Reading the information in from the text file
      iCounterNumber = Cdbl(objCounterFile.ReadLine) + 1
      strLastIP = Cstr(objCounterFile.ReadLine)
      objCounterFile.Close
    Else 
' If the doesn't exist start counting at 1
      iCounterNumber = 1
    End If
'
' If the current visitor's IP is different from the last visitor's IP then log the new information
    If (strLastIP <> strCurrentIP) then
      Set objCounterFile = objFSO.CreateTextFile(strFilePath, True)
      objCounterFile.WriteLine(iCounterNumber)
      objCounterFile.WriteLine(strCurrentIP)
      objCounterFile.Close
    Else 
      iCounterNumber = iCounterNumber - 1
    End If
'
' Destroying the Objects
    Set objCounterFile = Nothing
    Set objFSO = Nothing
'
'  Setting up the number to be displayed
'  This setup allows for later changing to images from text
    strCounterNumber = CStr(iCounterNumber)
    While (Len(strCounterNumber) > 0)
      strImageName = Left(strCounterNumber, 1)
      If (displayOption = UseText) then
	Response.Write (strImageName)
      Elseif (displayOption = UseImages) then
	Response.Write ("<IMG SRC=""" & imageDirectory & strImageName & ".gif"" BORDER=0>")
      End If
      strCounterNumber = Mid(strCounterNumber, 2)
    Wend
%>


The output is simple Times Roman at about 10/12pt.

How (or where) would I begin to format the output - to a differrnt font, say, or size, or maybe include it in a small box with a border?

Many thanks for any ideas.

High1
0

#2 User is offline   craftygeek 

  • Dedicated Member
  • PipPip
  • Group: Members
  • Posts: 153
  • Joined: 17-March 10
  • Reputation: 8
  • Gender:Male
  • Location:Norfolk, UK
  • Experience:Advanced
  • Area of Expertise:Designer/Coder

Posted 17 March 2010 - 07:07 PM

I use php - not ASP, but it looks like the counter is currently set to display as images rather than text.

change the 'displayOption' to equal 1 (not 0), this should then display the counter as text....I would then imagine that you should be able to alter the text size by using CSS.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users