Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ptsfa!ames!oliveb!sun!steved From: steved@sun.UUCP Newsgroups: comp.lang.fortran Subject: Re: Problem with substrings Message-ID: <20281@sun.uucp> Date: Wed, 3-Jun-87 14:33:29 EDT Article-I.D.: sun.20281 Posted: Wed Jun 3 14:33:29 1987 Date-Received: Sat, 6-Jun-87 03:46:32 EDT References: <286@nikhefh.UUCP> Reply-To: steved@sun.UUCP (Steve Dever) Distribution: world Organization: Sun Microsystems, Mountain View Lines: 35 In article <286@nikhefh.UUCP> i91@nikhefh.UUCP (Fons Rademakers) writes: >Does somebody know what according to the FORTRAN 77 standard >should happen in the following substring expression: > > CHARACTER*10 CH, STR > > STR = 'ABCDEFGHIJ' > I = 6 > NC = 0 > CH = 'FOO'//STR(I:I+NC-1)//'BAR' > The results of this program fragment are undefined. The FORTRAN 77 standard states (section 5.7.1) that in a substring reference of the form: V ( e1 : e2) "The values of e1 and e2 *must* be such that: 1 <= e1 <= e2 <= len where len is the length of the character variable or array element" So a program with a substring like this is does not conform to the standard. The standard does not prohibit a FORTRAN implementation from accepting this as an extension nor does it require that it signals an error either. -- --------------------------- Steve Dever steved@Sun.COM or Sun Microsystems sun!steved