Forum Moderators: open

Message Too Old, No Replies

txt file and string

         

laura2k

11:49 am on Feb 5, 2004 (gmt 0)



Hello,

I have the following code that reads the content of data.txt and displays it.

I dont want to read the entire txt file. In the text file i have data stored in the following format:

&name1=NAME&email1=email@email.com&name2=NAME2&email2=email2@email.com

so the file goes on and on like that and the only thing different about each set of data is that each data has a a number. For example, if i wanted the name and email address for the first entry, i will look at the value for &name1= and &email1=

That is exactly what i want to do. I want to read the value of just &name1= and &email1= and then display it.

the code below displays everything.

<%
dim filesys, text, readfile, strLink

set filesys = CreateObject("Scripting.FileSystemObject")

set readfile = filesys.OpenTextFile("data.txt", 1, false)

strLink = readfile.ReadAll

readfile.close

Response.Write strLink
%>

any help would be appreciated.

thanx in advance

wardbekker

10:40 pm on Feb 6, 2004 (gmt 0)

10+ Year Member



laura2k,

Your lucky! this is one of the reasons people invented databases. This data should be saved or otherwise imported in a datatable and you can query it with SQL, really ;-)

laura2k

10:57 pm on Feb 6, 2004 (gmt 0)



well basically the problem is that i have a application that stores data in this format, but i want to make a script that just takes the value of &name1= and &email1= and display it to me.

Xoc

2:47 pm on Feb 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So you just want to parse the text file? You will find the instr() and split() functions to be your friend.