And also:  ForAppending = 8, useful for writing logs

--- Dan Powderhill <[EMAIL PROTECTED]> wrote:

> ForWriting and ForReading are constants that need defining before they can be
> used. Try putting this at the top of your code (within the script tags) :-
> 
> Const ForReading = 1, ForWriting = 2
> 
> Dan
> www.diado.com
> 
> -----Original Message-----
> From: Cynthia Leslie [mailto:[EMAIL PROTECTED]
> Sent: 08 September 2004 14:22
> To: [EMAIL PROTECTED]
> Subject: Re: [AspClassicAnyQuestionIsOk] "Undefined" error when using
> FSOw/ForReading, etc.
> 
> 
> Hello, Dan.
> 
> I've pasted a code sample below. 
> 
> The error message that I'm getting in my browser window is:
> 
> a.. Error Type:
> Microsoft VBScript runtime (0x800A01F4)
> Variable is undefined: 'ForWriting'
> /dynamic/cgi.bin/ForWritingUndefined.asp, line 29
> 
> Interestingly, while I was preparing this code sample, I stumbled across the
> code in "ThisSubWorks" (on the Internet) and found that it actually does seem
> to work okay. Notice that the code in "ThisSubWorks" works does not make use
> of the ForReading, ForWriting, or ForAppending constants.
> 
> Prior to today, I had not had any success when trying to use the
> FileSystemObject to read or write any files from an ASP page -- though I am
> using it successfully from VB. However, when I first tried to use the
> FileSystemObject (with ForReading, ForWriting, or ForAppending) from VB, it
> didn't work. Eventually I found out that I had to use the VB project menu to
> create a reference to "Microsoft Scripting Runtime" -- after I did that, it
> worked okay. That's why I think that I probably need to do something
> analagous to that in order to use similar code in my ASP pages, which are
> running under Windows 2000/IIS.
> 
> 
> <% @Language="VBScript" %>
> <% Option Explicit %>
> 
> <SCRIPT LANGUAGE=VBScript RUNAT=SERVER>
> 
> Sub ThisSubWorksdim filesys, filetxt, getname, path
> Set filesys = CreateObject("Scripting.FileSystemObject")
> Set filetxt = filesys.CreateTextFile("c:\file_1.txt", True)
> path = filesys.GetAbsolutePathName("c:\file_1.txt")
> getname = filesys.GetFileName(path)
> filetxt.WriteLine("Bozo The Clown wears lots of makeup")
> filetxt.Close
> If filesys.FileExists(path) Then
>     Response.Write ("Your file, '" & getname & "', has been created.")  
> End If
> Set filetxt = Nothing
> Set filesys = Nothing
> End Sub
> 
> Sub ThisSubDoesNotWork
> 
> dim filesys, file, file_ts
>     Set filesys = CreateObject("Scripting.FileSystemObject")
>     filesys.CreateTextFile "C:\file_2.txt", True
>     Set file = filesys.GetFile("C:\file_2.txt")
>     Set file_ts = filesys.OpenAsTextStream(ForWriting)
> file_ts.WriteLine "Bozo The Clown wears lots of makeup"
> file_ts.Close
> Set file_ts = Nothing
> Set file = Nothing
> Set filesys = Nothing
> End Sub  
> </SCRIPT>
> 
> <html>
> <head>
> </head>
> <body>
> <%
> Response.Write "Calling sub ThisSubWorks"
> call ThisSubWorks
> 
> Response.Write "Calling sub ThisSubDoesNotWork"
> call ThisSubDoesNotWork
> %> 
> </body>
> </html>
> 
>   ----- Original Message ----- 
>   From: Dan Powderhill 
>   To: [EMAIL PROTECTED] 
>   Sent: Wednesday, September 08, 2004 8:15 AM
>   Subject: RE: [AspClassicAnyQuestionIsOk] "Undefined" error when using FSO
> w/ForReading, etc.
> 
> 
>   Can you show us the code that's causing the error?
> 
>   Dan
>   www.diado.com
> 
>   -----Original Message-----
>   From: Cynthia Leslie [mailto:[EMAIL PROTECTED]
>   Sent: 08 September 2004 13:08
>   To: [EMAIL PROTECTED]
>   Subject: [AspClassicAnyQuestionIsOk] "Undefined" error when using FSO
> w/ForReading, etc.
> 
> 
>   Hi.
> 
>   Can somebody tell me why I'm getting an "undefined" error for ForReading,
> ForWriting, and ForAppending when attempting to use the FileSystemObject in
> an ASP page? I think I might have to register a DLL to make it work?? If so,
> which one?
> 
>   Thanks.
> 
>   - Cynthia Leslie
> 
>   [Non-text portions of this message have been removed]
> 
> 
> 
>   Yahoo! Groups Sponsor      
> 
>   ADVERTISEMENT
>  
>
<http://us.ard.yahoo.com/SIG=1297l16p2/M=298184.5285298.6392945.3001176/D=groups/S=1705006764:HM/EXP=1094731803/A=2319498/R=0/SIG=11thfntfp/*http://www.netflix.com/Default?mqso=60185352&partid=5285298>
> click here      
>    
>
<http://us.adserver.yahoo.com/l?M=298184.5285298.6392945.3001176/D=groups/S=:HM/A=2319498/rand=388449500>
>       
> 
> 
>     _____  
> 
>   Yahoo! Groups Links
> 
> 
>   *      To visit your group on the web, go to:
>   http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
>     
> 
>   *      To unsubscribe from this group, send an email to:
>   [EMAIL PROTECTED]
>
<mailto:[EMAIL PROTECTED]>
> 
>     
> 
>   *      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/> . 
> 
> 
> 
> 
>   [Non-text portions of this message have been removed]
> 
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>              
>        
>        
> 
> 
>
------------------------------------------------------------------------------
>   Yahoo! Groups Links
> 
>     a.. To visit your group on the web, go to:
>     http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
>       
>     b.. To unsubscribe from this group, send an email to:
>     [EMAIL PROTECTED]
>       
>     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> 
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> Yahoo! Groups Sponsor
> ADVERTISEMENT
> 
> 
> 
> 
> 
> 
> Yahoo! Groups Links
> 
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
>   
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>   
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 
> 



                
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush


------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to