MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

If and openwrite and openappend


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



  • Prev by Date: Re: LinkInterrupt in C
  • Next by Date: Re: partition of 2D arrray
  • Previous by thread: Re: how to convert a matrix to a graphy
  • Next by thread: Re: If and openwrite and openappend