?
Solved

Documentation for    OpenTextFile()  [what are the parameters?]

Posted on 2003-03-30
2
Medium Priority
?
969 Views
Last Modified: 2008-03-06
Got a Global.asa which logs movements between pages and using code like:

  Set WriteStream = FileStreamObject.CreateTextFile(DataPath(sFilename),True)
  WriteStream.WriteLine("SessionID=" & Session.SessionID)
  WriteStream.WriteLine(sEvent & "=" & Now())
  WriteStream.WriteLine("KB_VER=" & KB_VER)
  WriteStream.Close

but I want to use OpenTextFile()   instead so the log file appends new info.
The book said use  OpenTextFile("file.log",ForAppending)  

but it doesn't work where do I get the value of 'ForAppending' etc.

0
Comment
Question by:BJStearn
2 Comments
 
LVL 39

Accepted Solution

by:
appari earned 200 total points
ID: 8236098
from MSDN:

OpenTextFile Method
Opens a specified file and returns a TextStream object that can be used to read from, write to, or append to the file.

object.OpenTextFile(filename[, iomode[, create[, format]]])

Arguments
object

Required. Always the name of a FileSystemObject.

filename

Required. String expression that identifies the file to open.

iomode

Optional. Indicates input/output mode. Can be one of three constants: ForReading, ForWriting, or ForAppending.

create

Optional. Boolean value that indicates whether a new file can be created if the specified filename doesn't exist. The value is True if a new file is created; False if it isn't created. The default is False.

format

Optional. One of three Tristate values used to indicate the format of the opened file. If omitted, the file is opened as ASCII.

Settings
The iomode argument can have either of the following settings:

Constant Value Description
ForReading 1 Open a file for reading only. You can't write to this file.
ForWriting 2 Open a file for writing only. You can't read from this file.
ForAppending 8 Open a file and write to the end of the file.


The format argument can have any of the following settings:

Constant Value Description
TristateUseDefault -2 Opens the file using the system default.
TristateTrue -1 Opens the file as Unicode.
TristateFalse 0 Opens the file as ASCII.


Remarks
The following code illustrates the use of the OpenTextFile method to open a file for writing text:

Sub OpenTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.Write "Hello world!"
   f.Close
End Sub
0
 

Author Comment

by:BJStearn
ID: 8247745
Thanks for that
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question