Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 how to read txt file?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Freeman II
Junior Member

232 Posts

Posted - 30 July 2001 :  14:44:20  Show Profile
i wanna make a table using ASP, and the asp file reads a txt file to get the data. just like using a DB. my question is how to use commas to seperate columns and line breaks to seperate rows. can someone give me an example?

this is what i got so far but it reads only 1st line.


<%
myfile = "asd.txt"
%>
<%
DIM myfso, myStream

Set myfso = CreateObject("Scripting.FilesystemObject")
If myfso.FileExists(Server.MapPath(myFile)) then
Set myStream = myfso.OpenTextFile(Server.MapPath(myFile), "1", "0")
i=1
Do While (Not myStream.AtEndOfStream) and (i < myLine)
myStream.SkipLine()
i = i+1
loop
if myStream.AtEndOfStream then
myMsg = ""
else
myMsg = myStream.ReadLine
myline = i
end if
myStream.Close
set myStream = nothing
set myfso = nothing
else
myMsg = ""
end if%>

<tr>
<td width="20%" align="center"><% =myMsg %></td>
<td width="20%" align="center"> </td>
<td width="20%" align="center"> </td>
<td width="20%" align="center"> </td>
<td width="20%" align="center"> </td>
</tr>

only the first cell is displayed.

this is what i have in asd.txt
12sda2sdfdsasdf
31:49 PM 30/07/20011:49 PM 30/07/2001
asdf


Spoon
Average Member

Ireland
507 Posts

Posted - 30 July 2001 :  17:18:43  Show Profile  Visit Spoon's Homepage  Send Spoon an ICQ Message
hehe, what?

Use a database of you can. I've read articles on reading from txt files, but its incredibly messy and not very versatile



Regards - Spoon

Begineer? Need help installing the forums? - www.aslickpage.com/snitz_help.html

www.ASlickPage.com - Private Messaging
Go to Top of Page

Id
Junior Member

USA
129 Posts

Posted - 30 July 2001 :  17:42:12  Show Profile  Visit Id's Homepage
you could use the split function, i.e. ArrayVar = Split(strName, ",") then it divides the string into sections that are broken apart by a comma and then puts them into an array. The only problem with this is the split function can only break up by what's inbetween the "" (you could do Split(strName, ": ;") and it would work fine but not Split(strName, " ", ",")

That might work for you

Going insane one day at a time
Go to Top of Page

Freeman II
Junior Member

232 Posts

Posted - 31 July 2001 :  17:45:32  Show Profile
i have a problem, it only reads the first line. how do you code a loop so the server reads every line of the text file?

Go to Top of Page

Kat
Advanced Member

United Kingdom
3065 Posts

Posted - 03 August 2001 :  05:36:50  Show Profile  Visit Kat's Homepage
Have a look at these articles:

http://msdn.microsoft.com/scripting/default.htm?/scripting/vbscript/doc/sgworkingwithfiles.htm

http://support.microsoft.com/support/kb/articles/Q300/9/82.asp?sd=MSDN

They should help.

KatsKorner
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20595 Posts

Posted - 03 August 2001 :  06:32:47  Show Profile  Visit HuwR's Homepage
you could also check out the admin_mod_dbsetup.asp which comes with v33, it parses a text file to create the DB update scripts.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07