Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!apple!rutgers!texbell!bigtex!texsun!newstop!sun!chiba!khb From: khb%chiba@Sun.COM (Keith Bierman - SPD Advanced Languages) Newsgroups: comp.lang.fortran Subject: Re: Position in file after open? Message-ID: <126396@sun.Eng.Sun.COM> Date: 16 Oct 89 17:50:16 GMT References: <1162@atha.AthabascaU.CA> <50500152@uxe.cso.uiuc.edu> Sender: news@sun.Eng.Sun.COM Reply-To: khb@sun.UUCP (Keith Bierman - SPD Advanced Languages) Organization: Sun Microsystems, Mountain View Lines: 52 In article <50500152@uxe.cso.uiuc.edu> mcdonald@uxe.cso.uiuc.edu writes: > >/* Written 2:19 pm Oct 14, 1989 by lyndon@cs.AthabascaU.CA in uxe.cso.uiuc.edu:comp.lang.fortran */ >/* ---------- "Position in file after open?" ---------- */ >Can someone enlighten me as to what the ANSI F77 spec has to say >about where a file pointer sits immediately after an open? As is moderately well known, this is a "feature" of the '77 standard. While it is "obvious" that a freshly opened file should be positioned at the start, there is a legend that at least one popular compiler positions to the end of file just to prove to customers how bad the standard is ... > > > OPEN(UNIT = 9,FILE = 'ALREADYEXISTS', STATUS = 'UNKNOWN') > REWIND(9) > >Is "unknown" a standard contruct or not? If so, should this always Unknown is perfectly standard ... but it doesn't address the positioning question at all. The f8x standard does. OPEN(UNIT = 9,FILE = 'ALREADYEXISTS', STATUS = 'UNKNOWN', & POSITION = pos) where pos is a character expression which ignoring trailing blanks and converting any lower-case letters to upper-case, has the value ASIS, REWIND, or APPEND. The default (in F8x as currently drafted) is to open a file to its start. While this is what nearly everyuser ever asked wants ... it has the _potential_ of breaking some outlandish program which was never ported to another machine (as most vendors learned that users really don't like to have to follow every open with a rewind ... and consider such behavior a bug) ... >begin writing at the begiining of file, overwriting anything alreay >there? > >IF not legal, is there any legal way to overwrite a file besides >attempting to open it for read, and if there closing it with a >delete specifier, themn opening a new file for write? That appears >to be the only way to do it in an oddball Fortran compiler I have >(MicroWay NDPC for the 386). > >Doug McDonald I don't understand the MicroWay problem ... doesn't the open/rewind/write work on that system ? If not, (a) file a bug report, (b) open, close (status=delete), open ? Keith H. Bierman |*My thoughts are my own. !! kbierman@sun.com It's Not My Fault | MTS --Only my work belongs to Sun* I Voted for Bill & | Advanced Languages/Floating Point Group Opus | "When the going gets Weird .. the Weird turn PRO"