Path: utzoo!attcan!uunet!world!burley From: burley@world.std.com (James C Burley) Newsgroups: comp.lang.fortran Subject: Re: String manipulation. Message-ID: Date: 24 Oct 90 07:15:28 GMT References: Sender: burley@world.std.com (James C Burley) Distribution: comp Organization: The World Lines: 32 In-Reply-To: quan@sol.surv.utas.oz's message of 23 Oct 90 23:53:35 GMT In article quan@sol.surv.utas.oz (Stephen Quan) writes: I need to do some string manipulation with a type : character*128. Can I do the following? character*128 str1 character str2(128) equivalence (str1,str2) Yes, unless str1 or str2 are dummy arguments or some such thing. However, I'm not sure what such an equivalence will buy you offhand. For example, given the above, any reference to STR2(N) should be identical to a reference to STR1(N:N) (a substring reference). If you have a FORTRAN 77 compiler, it should support substring references. There are a few places, however, where FORTRAN 77 does not support substring references but does support array references -- for example, EQUIVALENCE (though I think Fortran 90 is extending EQUIVALENCE to support substrings) and the implied-DO form of a DATA statement (though what you'd do with a substring reference within this form within the constraints of the standard, I can't think of offhand!). But in executable statements, I think you can always use substring references wherever you can use array references, and you can even use both, as in STR2(N)(1:1). (In case you don't know, a substring reference, FOO(begin:end), specifies a string characters long starting with the th character of FOO, where the first character is numbered 1. Omit begin, and 1 is the default; omit end, and the declared or assumed length of the variable is the default (i.e. thru the end of the string). One cannot omit the colon, or it looks like an array element or function reference. You can use substring references on the left side of an assignment, in a READ statement, and so on.) James Craig Burley, Software Craftsperson burley@world.std.com