Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read() method from the bottom of a text file

Status
Not open for further replies.

jasonsalas

IS-IT--Management
Jun 20, 2001
480
GU
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(&quot;<ul><li>Sent On: &quot; & ID & &quot;</li>&quot;)
buildFile.WriteLine(&quot;<li>Name: &quot; & name & &quot;</li>&quot;)
buildFile.WriteLine(&quot;<li>E-mail: &quot; & email & &quot;</li>&quot;)
buildFile.WriteLine(&quot;<li>Question: &quot; & question & &quot;</li></ul>&quot;)
buildFile.WriteLine(&quot;<li>Posted By: &quot; & IP & &quot;</li>&quot;)
buildFile.WriteLine(&quot;<hr width=&quot;&quot;65%&quot;&quot;>&quot;)

buildFile.Close

I'd like to read from the last line of the text file, the &quot;ID&quot; 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?
 
how about
DO UNTIL myFile.EOF I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
Not sure...it needs to read the last line in the file and extract the value of the last ID...and then add &quot;1&quot; to it. Got any ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top