What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » OpenTextFile & DeleteFile

OpenTextFile & DeleteFile
Author: Message:
personne3000
New Member
*


Posts: 2
Joined: Jan 2008
O.P. OpenTextFile & DeleteFile
Well... What would be said.. Hi?

I'm French and not so good at speaking English. So I won't spend my time writing a long message...

Why do these two codes give different results?


code:
fso.DeleteFile(chemin_fichier_calendrier);
fichier2 = fso.CreateTextFile(chemin_fichier_calendrier, 2, false);


code:
fichier2 = fso.CreateTextFile(chemin_fichier_calendrier, 2, true);

The file at "chemin_fichier_calendrier" always exists when these instructions are read.
Isn't the "true" parameter at the end of the "CreateTextFile" command supposed to overwrite the existing file?

The first possibility is the one that works for me. The second one gives... strange results, the output file isn't as I expect it to be (unexpected spaces and characters that I can't find on my keyboard...).

Thx :D
01-05-2008 05:00 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: OpenTextFile & DeleteFile
You have your parameters wrong:
code:
FileSystemObject.CreateTextFile
object.CreateTextFile filename [, overwrite[, unicode]]
That means:
  • filename is the path to the file to be created.
  • overwrite is a Boolean defining whether the existing file may be overwritten.
  • unicode is a Boolean defining whether the text file should be saved as Unicode (true) or AscII (false, default).
That means that the '2' is interpreted as a Boolean for the overwrite parameter and becomes converted to 'true', and that the 'true' or 'false' in your last parameter actually changes the text encoding. This is what causes your "strange characters" (which aren't strange at all, in fact).

To fix this, just leave out the invalid '2' parameter. This way, your true/false are correctly sent as overwrite parameter. :)
code:
fichier2 = fso.CreateTextFile(chemin_fichier_calendrier, true); //Allow overwrite
fichier2 = fso.CreateTextFile(chemin_fichier_calendrier, false); //Don't allow overwrite

This post was edited on 01-06-2008 at 09:40 AM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
01-06-2008 09:39 AM
Profile E-Mail PM Web Find Quote Report
personne3000
New Member
*


Posts: 2
Joined: Jan 2008
O.P. RE: OpenTextFile & DeleteFile
OOhh right !

I think I used Ctrl + C - Ctrl + V a little bit too much :p
I had copied the syntax of "OpenTextFile" actually..

var Mefile = ObjSys.OpenTextFile(path, [ Mode [, Create? [, Format]]])

The "2" was supposed to be the mode (ForWriting) but I guess I just don't need it.

Thx :D

(And sorry about the language... I'm doing my best :P)
01-06-2008 11:33 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On