"Type mismatch" error in JScript - newby question



Hi all,

I'm trying to create a simple text file that will allow a string of text to
be entered into it.

The script firstly creates the text file (which works well), but when I try
to then open that file for writing into it, I keep on getting a "type
mismatch" error. I'm very new to JScripting.

Here is the code:

<script language="JScript">

var fso = new ActiveXObject("Scripting.FileSystemObject");

var TheFile = fso.CreateTextFile("C:\\Test.txt", true); //creates the file,
and will overwrite if file already exists

var txtStream = fso.OpenTextFile(TheFile, 2, true); //opens the file for
writing
txtStream.WriteLine("Test Data to write");

</script>


Thanks very much for your help.
Karen
.



Relevant Pages

  • Program To Pattern Match
    ... I'm looking for a built-in program, aside from writing the obvious ... one/two line script, that does this: ... Where program would return 0 if match was successful. ... was a 'grep' that accepts a string instead of a file/stream. ...
    (comp.unix.shell)
  • Re: eval() or call_user_func() ???
    ... script (not a string). ... I am writing a simplified 'clone' of crontab, ... tasks - the tasks vbeing stored in a database table - I'm not ...
    (comp.lang.php)
  • Sending HTML file as mail from mail command (mail -s )
    ... of users for which i have developed a script and it is working fine. ... For the body of the mail i am writing into a text file everytime and i ... Mazhar ... Prev by Date: ...
    (perl.beginners)
  • Re: Script to search an input file, insert a line and then update the file
    ... sample code in writing a script which can perform the function in the ... subject line, i.e. read in a file, search for specific string, if the ...
    (comp.unix.shell)
  • List of files to be opened
    ... I am currently writing a script that requires a few different ... Gurus'Network - Are you a guru? ... Prev by Date: ...
    (comp.lang.python)