SUBROUTINE FILEND ( filnam ) C+ C SUBROUTINE FILEND C C Environment: C Env. Vsn: V 1.00 C C Subroutine/Function Description: C C Finds the first blank or nul and makes sure its a nul, so a character- C string file name can be used in an OPEN statement. For some reason, C DEC wants to use ASCIIZ strings only for opening files. An ASCIIZ C string ends with a nul, or 0, byte, at the last significant position. C C Parameter List: C Name Type I/O Purpose C -------------------------- ------------- ------ ------------------------ C C filnam Character*50 I/O File name to stick C nul onto. C C Data Structures: C COMMON Blocks: NONE C C C Side effects: The input arguement is modified. C C C------------------------------------------------------------------------- C Environmental Requirements C C Re-compile Procedure: [tbs] C Compile Command: [tbs] C Library: [tbs] C Modules called: [tbs] C C Test Procedures: C Test Data Files: [tbs] C Test Scripts: [tbs] C Documents: [tbs] C C Module Documentation: C Help File: [tbs] C Document File: [tbs] C C Required Logicals: [tbs] C C Required Files: [tbs] C C C Written By: Robert Hays C KMS Fusion, Inc. C P.O. Box 1567 C Ann Arbor, Mich. 48106 C C Ident: RLH01 C Date: December 23, 1985 C C C Change Log: C Date Initials Ident Description C [dd-mmm-yy] [tbs] [tbs] [tbs......] C---------------------------------------------------------------------------- C- C IDENT /1.00/ C CHARACTER*50 filnam ! File name. CHARACTER*1 blnk, ! Blank character. + nul ! Nul character C INTEGER*2 endfil INTEGER*2 posblk INTEGER*2 Posnul C DATA Blnk/' '/ DATA Nul/0/ C C Executable begins here. C C Find end of file name. We need to insert a nul if its not already C there. C posblk = INDEX ( filnam, blnk ) posnul = INDEX ( filnam, nul ) IF( posnul .NE. 0 .AND. posblk .NE. 0 ) THEN C C Take the least (earliest occurance) of the end-of-string. C endfil = MIN ( posnul, posblk ) C ELSEIF( posblk .NE. 0 ) THEN C C No nuls, so use first blank. C endfil = posblk C ELSEIF( posnul .NE. 0 ) THEN C C No blanks, so use nul. C endfil = posnul ELSE C C Nothing, so set to end of string. C endfil = LEN ( filnam ) END IF C C Set a nul at end of file name. C filnam(endfil:endfil) = nul C RETURN END