NAME index, rindex, lnblnk, len - get index or length of sub- string SYNOPSIS/USAGE CHARACTER*(*) string, substr n = INDEX (string, substr) INTEGER*4 FUNCTION rindex CHARACTER*(*) string, substr n = rindex (string, substr) INTEGER*4 FUNCTION lnblnk CHARACTER*(*) string n = lnblnk (string) CHARACTER*(*) string n = LEN (string) DESCRIPTION INDEX(a1,a2) returns the index of the first occurrence of string a2 in string a1, or zero if it does not occur (intrinsic function). rindex(a1,a2) returns the index of the last occurrence of string a2 in string a1, or zero if it does not occur. lnblnk( a1 ) returns the index of the last non-blank charac- ter in a1. This function is useful since all f77 character objects are of fixed length and blank-padded. LEN returns the declared size of the character string argu- ment (intrinsic function). NOTES When compiling for 64-bit environments (with compiler option -xarch=v9 or v9a), routines len, index, rindex, and 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. EXAMPLE Example: LEN(), INDEX(), rindex() , lnblnk(): 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 demo% f77 -silent tindex.f demo% a.out 32 24 1 21 demo% In the above example, declen is 32, not 24. This is the declared length of the character variable, not the length of the string it contains. FILES libF77.a
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |