.\" @(#)index.3f 1.3 86/01/02 SMI; from UCB 4.2 .TH INDEX 3F "98/09/17" .SH NAME index, rindex, lnblnk, len \- get index or length of substring .SH SYNOPSIS/USAGE .\" .nf .na .B CHARACTER*(*) string, substr .B n = INDEX (string, substr) .sp .B INTEGER*4 FUNCTION rindex .B CHARACTER*(*) string, substr .B n = rindex (string, substr) .sp .B INTEGER*4 FUNCTION lnblnk .B CHARACTER*(*) string .B n = lnblnk (string) .sp .B CHARACTER*(*) string .B n = LEN (string) .SH DESCRIPTION .B "INDEX(a1,a2)" returns the index of the first occurrence of string .B a2 in string .BR a1 , or zero if it does not occur (intrinsic function). .PP .B "rindex(a1,a2)" returns the index of the last occurrence of string .B a2 in string .BR a1 , or zero if it does not occur. .PP .B "lnblnk( a1 )" returns the index of the last non-blank character in .BR a1 . This function is useful since all .B f77 character objects are of fixed length and blank-padded. .PP .B LEN returns the declared size of the character string argument (intrinsic function). .SH NOTES When compiling for 64-bit environments (with compiler option .B -xarch=v9 or .BR v9a ), routines .BR len , .BR index , .BR rindex , and .B lnblnk could return values greater than the data range of INTEGER*4 data when applied to very large character strings (greater than 2 Gbytes). In this situation, these functions must be declared INTEGER*8, as well as the variables receiving their results. .SH EXAMPLE Example: .BR LEN() , .BR INDEX() , .B rindex() , .BR lnblnk() : .sp .nf .ft 3 CHARACTER s*32 / '123456789 123456789 1234' / INTEGER*4 declen, first, last, lnblnk, rindex declen = LEN( s ) first = INDEX( s, '123' ) last = rindex( s, '123' ) lastnb = lnblnk( s ) PRINT*, declen, lastnb, first, last END .ft 1 .fi .sp demo% .B "f77 -silent tindex.f" .br demo% .B a.out .br 32 24 1 21 .br demo% .sp In the above example, .B declen is 32, not 24. This is the declared length of the character variable, not the length of the string it contains. .fi .ad .SH FILES .B libF77.a