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

I have no idea what subject this is : )

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am new to ASP. I bought a book and started programming this:

<%@ Language=VBScript%>
<% option explicit %>
<% Response.Buffer = True %>

<%
Dim fs
Dim ts
Dim s
Dim aFile

aFile = &quot;set fs = server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
set ts = fs.OpenTextFile(aFile,ForReading,False)
s = ts.readall
ts.close
set ts=nothing

Response.Write s

%>

*Note that nlam700 is my local server where the file castle.html is found.


Now when I run this program I get the following:


Microsoft VBScript runtime error '800a01f4'

Variable is undefined: 'ForReading'

/scripts/rippage.asp, line 13



RIGHT!! How am I to open a file, if ForReading doesn't work?? Did I forget to include a file or something? pls help
 
Nope, the ForReading needs to be defined as a constant.

Put this right below the Dim statements...

Code:
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Hope this helps,
[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
there are some *.inc files you can include that will load all the constants for you. Like doing

[tt]

<%@ Language=VBScript %>
<!--<#include file=&quot;adovbs.inc&quot;>-->
...
[/tt]

will include a majority of predefined constants for use with ADODB , and some other scripting.

I dont know which of the scripting library files has constants for FileSystemObject, but using the constants above (from Rob) should be a quick sure way just for that need. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
Thanks so much for the fast replies!!! But now that I added these extra lines, I get this output:


Server object error 'ASP 0177 : 800a004c'

Server.CreateObject Failed

/scripts/rippage.asp, line 19

00000000
 
lets make sure you have the proper tools first

are you running least Windows NT4 with IIS4
or Win9x with PWS4?

also those constants yer supposed to stick them in above where ever yer going to use them, like say near the top but not above the <%Language.... [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
Technet has the following Q article : Q197964

Go to
Later, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
The only thing, that I can think of is:
for the path to the file you want to open, you need to use physical path as in:&quot;drive_letter:\directory_name\file_name&quot; and you need to have appropriate permissions to access this file.
 
OK, I loged in now.

Well, as I said, I'm new to ASP, so I really appreciate the help ;)

The system that I run on is Windows 98 (second edition) with PWS. The file (castle.html) is in the correct location, and this program should be able to work on the web...

I didn't include any files, and I think that is where it went wrong. I don't have any files to include... Any links?
Also, is it better to host it with another program? PWS sometimes stops sharing my web, but thats another problem.

Thanks in advance. [sig][/sig]
 
Thanks for the tip guestg (Visitor)!!! Opening the file from my HDD worked!! But the problem is, when I open a file from the internet, it comes back with the same error again... [sig][/sig]
 
McNash,

This still sounds like a permissions problem (have you viewed the Q article?).

Also, try to get your hands on Win2K Pro/Server (or at least NT4 with Option Pack 4). This will allow you to run IIS which is much better than PWS. You could then explore all the other things that a server environment has to offer (such as better security).

Later, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
The only remark - you need to have NT4 Server to be able to install IIS. Otherwise it still will be PWS.
As for permissions, I agree with Rob.
And both, file, which opens a text file and a text file itself, should be on a webserver.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top