?
Solved

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

Posted on 2003-03-30
2
Medium Priority
?
966 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

764 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