[comp.lang.pascal] soliciting advice

tpehrson@javelin.sim.es.com (Tim Clinkenpeel) (05/29/91)

i'd like to update a single record in a file of records (tp5.0).

is it possible to read and write a file at the same time or do i need to
open the file for read, find the record, save the file pointer position,
close the file, open the file for write, seek the pointer position and
write the record -OR- is there a method which i am unware of (efficiency
is what i seek).


-- 
   /=============================/ 
  / tpehrson@javelin.sim.es.com /      i will work for food 
 /=====aka: tim clinkenpeel====/ 
[DISCLAIMER: send SASE to: disclaimer, 84151-0521]

phys169@csc.canterbury.ac.nz (05/29/91)

In article <1991May28.215118.541@javelin.sim.es.com>, tpehrson@javelin.sim.es.com (Tim Clinkenpeel) writes:
> is it possible to read and write a file at the same time or do i need to
> open the file for read, find the record, save the file pointer position,
> close the file, open the file for write, seek the pointer position and
> write the record -OR- is there a method which i am unware of (efficiency
> is what i seek).
> 
Little Known Facts of Turbo Pascal #60103:
When you use the "reset(somefile)" procedure in T.P., unless you put in a line
before like "filemode:=64;" then it actually opens the file for reading AND
WRITING. Some documentation suggests reset is for reading only, and rewrite for
writing; ignore it. You don't even need to muck around with fmInOut, its done
for you already.

Warning to Remember about T.P. number R850:
You can accidentally change data files you open with the reset procedure; it
doesn't stop you from writing to them.

Mark Aitchison, Physics, University of Canterbury, New Zealand.
Trivia Question: what do the numbers 60103 (or 4472) and R850 have in common?

s2942275@techst02.technion.ac.il (Yaniv Golan) (05/29/91)

When you open a file with the RESET command it is opened for inputAND output,
so there is no need to open and close it again. Find the record you need to update, read it, change it, SEEK the same position again and write it back.

Yaniv Golan
s2942275@techst02.technion.ac.il