Hi I was wondering that if some of you had the time to look through my code and give me some crit (good or bad but only constructive) on this, my first self developed code.<BR><BR>It keeps a count of hits on individual pages... All I need to know is were I could have improved something or streamlined it or improve its performance. Also any "bad" usage of something pointed out would be helpful..<BR><BR>TIA<BR>Jason<BR><BR>-------------------------------------------------------------<BR>&#060;%<BR>Sub pageCount(strPageName)<BR>&#039------------------ NOTES ON USAGE ----------------------------<BR>&#039You only need to edit sections marked by "----manual edit (start)/(stop)---"<BR>&#039On pages using the page counter you must include this file using SSi and then call<BR>&#039the sub pageCount(strPageName) where strPageName is a name passed to the<BR>&#039sub. Dont forget the doble quotes e.g.:<BR>&#039 pageCount("mypage")<BR>&#039<BR>&#039The file that holds the values is a text file that must have the correct permissions.<BR>&#039The text file has one value per line/per page that you are counting.<BR>&#039Eg: If you are counting 3 pages then the txt file would be:<BR>&#0390<BR>&#0390<BR>&#0390<BR>&#039The page is named "pgcnt.txt"<BR>&#039--------------------------------------------------------------<BR> Dim FSOpgCnt, filePath, pgNum, looper<BR> Dim elementsQuant &#039Number of elements in the array, used in the write loop to<BR> &#039write all values in array into textfile.<BR> elementsQuant = 11<BR> Dim pgCntArray(12) &#039Array that holds values of each pages count, must be equal to or<BR> &#039greater than the total number of page count values<BR> <BR> &#039----------- Manual edit (start) ------------------------------------------------------------<BR> &#039Used in the SELECT CASE statements to correctly increment the correct array element number<BR> &#039depending on the value of the variable &#039strPageName&#039 that is passed to this sub-routine<BR> &#039--------------------------------------------------------------------------------------------<BR> &#039 You must add one for each page that will be using the page count and then add it in the<BR> &#039 appropriate place in the SELECT CASE statements<BR> &#039 "pgDefault = 0" for example will access the first elements in pgCntArray<BR> Const pgDefault = 0 <BR> Const pgMembers = 1 <BR> Const pgMain = 2 <BR> Const pgMemberForum = 3 <BR> Const pgChallenge = 4<BR> Const pgResults = 5<BR> Const pgLinks = 6<BR> Const pgAbout = 7<BR> Const pgPortfolio = 8<BR> Const pgMenu = 9<BR> Const pgCount = 10<BR> <BR> &#039----------- Manual edit (end) --------------------------------------------------------------<BR> &#039TextStream constants<BR> Const Writing = 2, Reading = 1, Appending = 8<BR> <BR> &#039Set the path to the text file to which we will be reading and writing.<BR> filePath = Server.MapPath("/db/stsdb/pgcnt.txt")<BR> <BR> &#039Set up the FileSystemObject to access and manipulate the text file.<BR> Set FSOpgCnt = Server.CreateObject("Scripting.FileSystemObject")< BR> Set txtFile = FSOpgCnt.OpenTextFile(filePath,Reading)<BR> <BR> &#039Reset looper variable to zero<BR> looper = 0<BR> <BR> &#039Iterate through the array reading each line and inserting the value into each element of pgCntArray<BR> While looper &#060; elementsQuant<BR> pgCntArray(looper) = txtFile.ReadLine<BR> looper = looper + 1 &#039Increment looper by 1 to prepare for next element<BR> WEND<BR> <BR> looper = elementsQuant<BR> <BR> &#039----------- Manual edit (start) ------------------------------------------------------------<BR> &#039 Determine which page made the call so that we can increment the correct value<BR> &#039<BR> &#039One for each page that calls uses the page counter<BR> &#039A page using this calls it like this for example:<BR> &#039 &#060;!-- #include file="pagecounter.asp" --&#062;<BR> &#039 &#060; % pageCount("default") % &#062; //This would increment the value held in pgCntArray(pgDefault)<BR> &#039pagecount.asp would be this file included into the page to use the page counter<BR> &#039------------------------------------------------------------------------------------------<BR> Select Case strPageName<BR> Case "default" <BR> pgCntArray(pgDefault) = pgCntArray(pgDefault) + 1<BR> Case "members"<BR> pgCntArray(pgMembers) = pgCntArray(pgMembers) + 1<BR> Case "main"<BR> pgCntArray(pgMain) = pgCntArray(pgMain) + 1<BR> Case "memberforum"<BR> pgCntArray(pgMemberForum) = pgCntArray(pgMemberForum) + 1<BR> Case "challenge"<BR> pgCntArray(pgChallenge) = pgCntArray(pgChallenge) + 1<BR> Case "results"<BR> pgCntArray(pgResults) = pgCntArray(pgResults) + 1<BR> Case "links"<BR> pgCntArray(pgLinks) = pgCntArray(pgLinks) + 1<BR> Case "about"<BR> pgCntArray(pgAbout) = pgCntArray(pgAbout) + 1<BR> Case "portfolio"<BR> pgCntArray(pgPortfolio) = pgCntArray(pgPortfolio) + 1<BR> Case "menu"<BR> pgCntArray(pgMenu) = pgCntArray(pgMenu) + 1<BR> Case "count"<BR> pgCntArray(pgCount) = pgCntArray(pgCount) + 1<BR> End Select <BR> <BR> &#039----------- Manual edit (end) --------------------------------------------------------------<BR> <BR> &#039Housekeeping, close files and set to point to nothing.<BR> txtFile.Close<BR> Set txtFile = nothing<BR> <BR> &#039Write to file to store values<BR> &#039Prepare the textfile for writing to.<BR> Set txtFile = FSOpgCnt.CreateTextFile(filePath,Writing)<BR> &#039Iterate through all array elemtns writing each value on a seperate line.<BR> &#039A new file is created over the old file each time to start with a "clean sheet"<BR> For looper = 0 to elementsQuant<BR> txtFile.WriteLine(pgCntArray(looper))<BR> Next<BR> <BR> &#039Housekeping<BR> txtFile.Close<BR> Set txtFile = nothing<BR> Set FSOpgCnt = nothing<BR><BR>End Sub<BR><BR><BR>%&#062;