C+ C NAME: C bCompareStr C PURPOSE: C Comparing strings, avoiding the traps of zero-length strings C CATEGORY: C String manipulation C CALLING SEQUENCE: logical function bCompareStr(ID,C1,C2) C INPUTS: C C1 character*(*) string to be processed C OUTPUTS: C CStr character*(*) modified string C L integer length non-trivial part of output string C SEE ALSO: C uppercase, lowercase, itrim, icompress, iwhitespace C PROCEDURE: C MODIFICATION HISTORY: C JAN-1992, Paul Hick (UCSD) C- integer ID character C1*(*) character C2*(*) parameter (N=80) character D1*(N) character D2*(N) bCompareStr = .FALSE. if (ID .eq. 0) then L1 = itrim(C1) L2 = itrim(C2) else if (len(C1) .gt. N .or. len(C1) .gt. N) return L1 = icompress(C1,D1) L2 = icompress(C2,D2) end if !------- ! C1 and C2 both zero length strings bCompareStr = L1 .eq. 0 .and. L2 .eq. 0 !------- ! Non-zero length strings with the same length if (.not. bCompareStr .and. L1 .eq. L2) then if (ID .eq. 0) then bCompareStr = C1(:L1) .eq. C2(:L2) else bCompareStr = D1(:L1) .eq. D2(:L2) end if end if return end