p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_codeclinic thread: I dont know why this scipt isnt working


Message #1 by "Mark Hopkins" <deft989@y...> on Thu, 14 Jun 2001 22:27:03
consider the READALL() method, and SPLIT()




At 10:27 PM 6/14/2001 +0000, you wrote:
>Hi, Im writing a browser logging counter script that doesn't work... yet
>Heres the error (Im using PWS so its ASP 2.0 I think)
>
>Microsoft VBScript runtime error '800a0009'
>
>Subscript out of range: '[number: 1]'
>
>/testingasp.asp, line 45
>
>Heres the whole scipt's code, I put a comment next to line 45 (there are
>probably some more errors, but I need to fix this one first)
>
>Const ForReading =3D 1, ForWriting =3D 2, ForAppending =3D 8 'File Things'
>   Const TristateDefault =3D -2, TristateTrue =3D -1, TristateFalse =3D 0
 'File
>Things'
>
>   LogFileName =3D Server.MapPath("/") & "\hitlog2.log"
>   Browser =3D Request.ServerVariables("HTTP_USER_AGENT")
>
>   set objFSO =3D CreateObject("Scripting.FileSystemObject") 'Made FSO'
>
>   'Create log if doesnt exist'
>   If objFSO.FileExists(LogFileName) =3D FALSE Then
>     Set objLogTS =3D objFSO.CreateTextFile(LogFileName)
>     ObjLogTS.WriteLine Browser
>     objLogTS.WriteLine 0
>     ObjLogTS.Close
>   End If
>
>   Dim Body()
>   ReDim Body(0)
>   Counter =3D 0
>
>   'Write all of the log to an array, one line per slot'
>   Set objLogTS =3D objFSO.OpenTextFile(LogFileName, ForReading)
>
>   Do While objLogTS.AtEndOfStream =3D FALSE
>     Body(Counter) =3D objLogTS.Readline
>     Counter =3D Counter + 1
>     ReDim Preserve Body(Counter)
>   Loop
>
>   Counter =3D Counter - 1
>   Redim Preserve Body(Counter - 1)
>   objLogTS.Close
>
>   'Determine of browser is in log already'
>   BrowserFound =3D FALSE
>   For Item =3D 0 to Counter
>     If Body(Item) =3D Browser Then
>       Body(Item + 1) =3D Body(Item + 1) + 1 'LINE 45 Add one to next slot
>(array in Browser,Hits format)'
>       BroswerFound =3D TRUE
>     End If
>   Next
>
>   If BrowserFound =3D FALSE Then
>     Redim Preserve Body(Counter + 2)
>     Body(Counter + 1) =3D Browser
>     Body(Counter + 2) =3D 1
>   End If
>
>   'Make a TextStream Object for writing'
>   Set objLogTS =3D objFSO.OpenTextFile(LogFileName, ForWriting)
>
>   'Write array to file'
>   For Item =3D 0 to Counter
>     objLogTS.WriteLine Body(Item)
>   Next
>
>I admit I dont have much experience with ASP.. so the error is probably
>pretty stupid.
>
>Thanks in advance
>

Robert Chartier
Author, AspFree.com
xxx-xxx-xxxx
rob@a...
http://www.aspfree.com/devlinks
http://www.aspfree.com/authors/robert
http://www.aspalliance.com/nothingmn


  Return to Index