jasonsalas
IS-IT--Management
Hi everyone,
I'm trying to figure out how to apply the VBScript Read() method to read from the bottom of a text file I have sitting on my server, the last line specifically. What I'm doing is trying to increment a value, so that every entry will have a unique ID, like a database would.
I'm using the following code to open and write to a text file:
Dim ID, name, email, question, FSO, buildFile, IP
ID = Now()
name = Request.Form("Name"
email = Request.Form("Email"
question = Request.Form("Question"
IP = Request.ServerVariables("REMOTE_ADDR"
Const ForAppending = 8
Const TriStateFalse = 0
Set FSO = Server.CreateObject("Scripting.FileSystemObject"
Set buildFile = FSO.OpenTextFile("C:\myFile.html",ForAppending,True,TristateFalse)
buildFile.WriteLine("<ul><li>Sent On: " & ID & "</li>"
buildFile.WriteLine("<li>Name: " & name & "</li>"
buildFile.WriteLine("<li>E-mail: " & email & "</li>"
buildFile.WriteLine("<li>Question: " & question & "</li></ul>"
buildFile.WriteLine("<li>Posted By: " & IP & "</li>"
buildFile.WriteLine("<hr width=""65%"">"
buildFile.Close
I'd like to read from the last line of the text file, the "ID" value, and then increase it by a value of 1, so that each time I post to this file, the value is incremented. Since Read() starts reading from the top-down, does anyone know how you can use the Read() method to read in reverse?
I'm trying to figure out how to apply the VBScript Read() method to read from the bottom of a text file I have sitting on my server, the last line specifically. What I'm doing is trying to increment a value, so that every entry will have a unique ID, like a database would.
I'm using the following code to open and write to a text file:
Dim ID, name, email, question, FSO, buildFile, IP
ID = Now()
name = Request.Form("Name"
email = Request.Form("Email"
question = Request.Form("Question"
IP = Request.ServerVariables("REMOTE_ADDR"
Const ForAppending = 8
Const TriStateFalse = 0
Set FSO = Server.CreateObject("Scripting.FileSystemObject"
Set buildFile = FSO.OpenTextFile("C:\myFile.html",ForAppending,True,TristateFalse)
buildFile.WriteLine("<ul><li>Sent On: " & ID & "</li>"
buildFile.WriteLine("<li>Name: " & name & "</li>"
buildFile.WriteLine("<li>E-mail: " & email & "</li>"
buildFile.WriteLine("<li>Question: " & question & "</li></ul>"
buildFile.WriteLine("<li>Posted By: " & IP & "</li>"
buildFile.WriteLine("<hr width=""65%"">"
buildFile.Close
I'd like to read from the last line of the text file, the "ID" value, and then increase it by a value of 1, so that each time I post to this file, the value is incremented. Since Read() starts reading from the top-down, does anyone know how you can use the Read() method to read in reverse?