Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!ufqtp!bernhold From: bernhold@qtp.ufl.edu (David E. Bernholdt) Newsgroups: comp.lang.fortran Subject: Re: length of a character string Keywords: null string, intrinsic function LEN Message-ID: <676@orange19.qtp.ufl.edu> Date: 20 Sep 89 00:24:28 GMT References: <18585@ut-emx.UUCP> Reply-To: bernhold@orange19 (David E. Bernholdt) Organization: University of Florida Quantum Theory Project Lines: 30 In article <18585@ut-emx.UUCP> reeder@ut-emx.UUCP (William P. Reeder) writes: >I was porting NCAR Graphics (version 2.01) to an Alliant... >I thought about using the intrinsic function LEN, but that just told me the >size of the character variable (80), not the length of the string stored >there (which may be less than 80). >I didn't see any standard >intrinsic function defined which might give me this information. 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. I just checked on an Alliant I have access to & its there. It is also present on Sun, Titan, Encore. It is not present on Balance or Cray, but for those and others it is quite easy to write in portable Fortran77. I have done this and use it in virtually all of my programs -- its the only way to get nice formatting of strings. I would be glad to send a copy to anyone who's interested, but its only 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! -- David Bernholdt bernhold@qtp.ufl.edu Quantum Theory Project bernhold@ufpine.bitnet University of Florida Gainesville, FL 32611 904/392 6365