home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!chx400!bernina!neptune!monagan
- From: monagan@inf.ethz.ch (Michael)
- Newsgroups: sci.math.symbolic
- Subject: Re: Maple question
- Summary: Maple problem with C translation
- Keywords: output file, C.
- Message-ID: <1992Aug28.142042.19584@neptune.inf.ethz.ch>
- Date: 28 Aug 92 14:20:42 GMT
- References: <1992Aug27.160913.14137@athena.mit.edu>
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- Lines: 41
- Nntp-Posting-Host: rutishauser-gw.inf.ethz.ch
-
- In article <1992Aug27.160913.14137@athena.mit.edu>, bhattas@athena.mit.edu (Saurav D Bhatta) writes:
- > i am writing a procedure that generates symbolic expressions which i want to use
- > in a C program. i want to output the expressions to a file. so my question is
- > basically this: how would i output stuff to a file in a format readable by a C
- > program.
- >
- > i tried the following methods:
- >
- > 1) > C(expression,filename = `test.out`);
- > the problem with this was that every time i used this command, the file was
- > overwritten. since my procedure is going to generate a lot of different
- > expressions which i want to output to the file, i definitely do not want the file
- > to be overwirtten every time i write out a new expression (want an append mode);
- >
-
- Dear Saurav,
-
- Yes, the C function and also the fortran function when given a filename for
- the output execute writeto(filename); which means the file gets overwritten.
- In the new versions, they execute appendto(filename); so the output
- is appended to the file. This is what you want. The new code is available
- in the Maple share library which you can get using anonymous ftp from
-
- Internet # Internet address Location Directory
- =================================================================
- 129.97.140.58 daisy.uwaterloo.ca Waterloo maple
- 129.132.101.33 neptune.inf.ethz.ch Zurich maple
-
- Actually, a little Maple majic will also fix the problem. Just subsitute
- the writeto call for appendto in the code by doing
-
- C := subs(writeto=appendto,readlib(C));
-
- However I recommend you try to get the new code as it contains a bug fix
- and will now breaks up large expressions which cause compilers to break.
- The reason why methods 2) and 3) that Saurav mentioned didn't work
- is because if one doesn't specify a filename, the old C and fortran codes
- explicitly write to the terminal, thus overriding the writeto(`test.out`);
- and open(`test.out`); statements Saurev used in methods 2) and 3).
-
- Michael Monagan
-