Jordan C N Chong wrote: > > I have a file, temp > which has the content: > p(1,2,3). > > I have run the following: > open(temp,update,File), > read(File,p(X,Y,Z)), > Q is X + Y + Z, > write(File,p(X,Y,Q)), > close(File). > > My question is, is it possible to overwrite p(1,2,3) to p(1,2,6)? > I have tried the above, it only appends p(1,2,6) at to the file. Update-streams have only one "file-pointer" which marks the "current position" in the file. After reading your p(X,Y,Z) term, the pointer points behind the term, and this is where the subsequent write operation writes. Depending on your exact problem, you could - open the file twice, once for reading and once for writing (so you have two file pointers) - use update mode as you have done, but use at/2 to remember the position before reading, and seek/2 to go back to that position before writing. -- Joachim Schimpf / phone: +44 20 7594 8187 IC-Parc / mailto:J.Schimpf@imperial.ac.uk Imperial College London / http://www.icparc.ic.ac.uk/eclipseReceived on Mon Jun 09 12:43:30 2003
This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:24 PM GMT GMT