Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!unmvax!brainerd From: brainerd@unmvax.unm.edu (Walt Brainerd) Newsgroups: comp.lang.fortran Subject: Re: length of a character string Summary: Here it is. Keywords: null string, intrinsic function LEN Message-ID: <386@unmvax.unm.edu> Date: 20 Sep 89 13:57:23 GMT References: <18585@ut-emx.UUCP> <676@orange19.qtp.ufl.edu> Organization: University of New Mexico at Albuquerque Lines: 31 In article <676@orange19.qtp.ufl.edu>, bernhold@qtp.ufl.edu (David E. Bernholdt) writes: > Many (not all, however) UNIX Fortrans include a function called LNBLNK > in their library. This returns the index of the "Last Non-BLaNK" > position in the string. > > 14 lines of actual code! > > BTW, the first public comment draft of the F8x standard included the same > function under a different name. I don't know if its still there, but > I hope so! Here is the mentioned function in 14 / 2 lines. Puzzle: even one of these lines is not necessary; which is it? This also illustrates how the LEN function is useful in a subprogram. It is still in F8x; the name is LEN_TRIM. Kind of silly when it could be a part of a standardized string-handling module. FUNCTION LENTRM (STRING) CHARACTER *(*) STRING DO 10 LENTRM = LEN (STRING), 1, -1 IF (STRING (LENTRM:LENTRM) .NE. ' ') RETURN 10 CONTINUE LENTRM = 0 END -- Walt Brainerd Unicomp, Inc. brainerd@unmvax.cs.unm.edu 2002 Quail Run Dr. NE Albuquerque, NM 87122 505/275-0800