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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read a text file

Status
Not open for further replies.

rondavid

Programmer
Apr 29, 2003
19
US
Hello everyone. Im a newbie. Can anyone tell me whats wrong with this code:
<%@ Language=VBScript %>
<%
Dim fso,f,datapath,rline,current
Dim aTxt(10)
Dim aTxtA(10)
datapath = Server.MapPath(&quot;events.txt&quot;)
'Response.Write datapath
Set f = fso_OpenTextFile(datapath,1)
Do While f.AtEndOfStream <> True
rline= f.ReadLine
if IsNumeric(rline) then
current = cint(rline)
else
if IsDate(rline) then
aTxt(Current) = rline
else
aTxtA(Current) = rline
end if
end if
loop
f.Close
%>
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
</HEAD>
<BODY>

<P><IMG alt=&quot;&quot;
src=&quot;file://C:\SourceCodeTechnologies\Projects\AVM Technologies\Web stuff\images\eventsguy.jpg&quot;></P>

</BODY>
</HTML>

I keeping it simple so I can learn, but this keeps giving me HTTP 500 Internal Server Error. Thanks
 
Nothing Much Wrong with the Code except you have not created the fso object before opening the text file .

'Copy/paste this line OF code written below
'above &quot;Set f=Set f = fso_OpenTextFile(datapath,1)&quot;

Set fso=server.CreateObject(&quot;Scripting.FileSystemObject&quot;)


'---YOUR CODE SHOULD BE LIKE THIS
<%
Dim fso,f,datapath,rline,current
Dim aTxt(10)
Dim aTxtA(10)
datapath = Server.MapPath(&quot;events.txt&quot;)
Set fso=server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set f = fso_OpenTextFile(datapath,1)
Do While f.AtEndOfStream <> True
rline= f.ReadLine

if IsNumeric(rline) then
current = cint(rline)
else
if IsDate(rline) then
aTxt(Current) = rline
else
aTxtA(Current) = rline
end if
end if
loop
f.Close



%>
'---END CODE
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top