Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!calvin!richard From: richard@calvin.EE.CORNELL.EDU (Richard Brittain) Newsgroups: comp.lang.fortran Subject: Re: Any way to fseek() in MS-Fortran under DOS? Summary: Why can't I free format read from a character string ? Message-ID: <490@calvin.EE.CORNELL.EDU> Date: 12 Jul 88 03:02:13 GMT References: <472@morgoth.UUCP> <11041@cgl.ucsf.EDU> Reply-To: richard@calvin.ee.cornell.edu.UUCP (Richard Brittain) Distribution: na Organization: Cornell Space Plasma Physics Group Lines: 34 In article <11041@cgl.ucsf.EDU> seibel@hegel.mmwb.ucsf.edu.UUCP (George Seibel) writes: >In article <472@morgoth.UUCP> dmb@morgoth.UUCP (David M. Brown) writes: >>What I want to do is look at the first character in the line, and, if >>it's a '#', just go on to the next line. No problem there. But, if it's >>not, then I want to read data from the rest of the line. >......... > >The usual approach is to read a line into a buffer, then test the buffer >to see if it has the characters that signify a real record. If it does, >read it using an internal read. In this example, I assume a max record >length of 80 chars, and read an integer and a real... ....... example deleted >... that's all. this is standard fortran 77, so you shouldn't have to >mess around with fseek(), and it should work on any fortran 77 compiler. ......... >You'll have to do formatted reads however; if you want to do a "free format ^^^^^^^^^^^ >read" from the buffer, then you'll have to parse it yourself. ^^^^ >George Seibel, UCSF >seibel@cgl.ucsf.edu This is a very common situation in a lot of the programming which I am involved in, and I find the inability to perform a free format read from a character string a constant frustration. I never use a formatted read when a free format read will do as this makes life so much easier. Can anyone explain a good reason for this rule in the fortran standard? It has always seemed somewhat arbitrary to me. Richard Brittain, School of Elect. Eng., Upson Hall Cornell University, Ithaca, NY 14853 ARPA: richard@calvin.ee.cornell.edu UUCP: {uunet,uw-beaver,rochester,cmcl2}!cornell!calvin!richard