If and openwrite and openappend
- To: mathgroup at smc.vnet.net
- Subject: [mg49183] If and openwrite and openappend
- From: "camartin at snet.net" <camartin at snet.net>
- Date: Tue, 6 Jul 2004 03:34:23 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
MathGroup,
Obviously I don't understand something about using If, etc.
I'm trying to write a piece of code to store strings in a file. A very
simplified example follows:
Clear[t]
Clear[nix]
nix[x_String, y_String] :=
t = {x, y}
If[FileType["c:\\Mathematica\\dBaspap"] == None,
stmp = OpenWrite["c:\\Mathematica\\dBaspap"],
stmp = OpenAppend["c:\\Mathematica\\dBaspap"]]
Write[stmp, t]
Close[stmp]
The function seems to work as I want if the file doesn't exist. If it
exists the code doesn't work.
If I the OpenAppend from the If statement things work fine. But a
subsequent use of nix fails because it refuses to open a stream.
I've read Wolfram fairly carefully I thought but I'm missing something
obvious.
Thanks for any help.
Cliff Martin