Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Re: StreamText File


Message #1 by "Daniel Menoni" <danm@f...> on Wed, 20 Nov 2002 15:48:57
Your best bet here is to open the file into a textstream and read each 
line sequentially into a string variable, use the instring(InStr) function 
to return the position of the character you are looking for and Mid to 
retrieve it.
So....

Dim ts As TextStream
Dim str As String

Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set ts=fs.OpenTextFile(Server.MapPath("/browseabit/new_sites/page.txt"), 1)
Do While Not ts.AtEndOfStream
str=ts.ReadLine
Response.Write(Mid(str,InStr(str,"u= "),InStr(str,"t= ")-InStr(str,"u= ")))
Loop




> Hello
>  
> I am awear of the following tasks:
> 
> Object reads from the opened text file.  
> 
> Read only a part of  a textfile
> Read one line of a textfile
> Read all lines from a textfile
> skip a specified number of characters when reading the TextStream file.
> Skip a line of a textfile
> Return line-number
> 
> Does somebody know how to find a specific caracter in the text file 
quick 
> and then I would return  the value of this specific caracter on the asp 
> page and loop through the text file.
> 
> Could somebody show me an exsample please how to pick up the letter u, 
t, 
> and k, from the text file and on my ASp page I return it like 
> 
> Set fs=Server.CreateObject("Scripting.FileSystemObject")
> Set f=fs.OpenTextFile(Server.MapPath("/browseabit/new_sites/page.txt"), 
1)
> Response.Write(f.Read(........????????
> 
> Exsample Text file :
> 
> _______
> 2438648846 2934792349837||some text|| u= http://www.somesite.com/folder 
> t=The title of the last page d= desription k= keywords
> 2438648846 2934792349837||some text|| u= http://www.somesite.com/folder 
> t=The title of the last page d= desription k= keywords
> 2438648846 2934792349837||some text|| u= http://www.somesite.com/folder 
> t=The title of the last page d= desription k= keywords
> 2438648846 2934792349837||some text|| u= http://www.somesite.com/folder 
> t=The title of the last page d= desription k= keywords
> ......
> ....
> ...
> ______
> 
> so I would have in textstream everything behind  the "u= ", "t= " ,....
> 
> Thanks for your help
> 

  Return to Index