Verify (string, set, back)

Function Type

Verify is a character intrinsic function.

Function Purpose

By default this function will search for the first position in a string of characters of a character that is not in the character variable or constant set. If the back=.true. argument is included, this function can then be made to search for the last position in the character variable or constant string of a character that does not appear in set. An integer corresponding to the position of the differing character will then be stored in a integer variable. If there are no characters in the character string that are different from those in set, then a value of zero will be reported.

Required Arguments

verify ( string, set )

String

String is the group of characters that you wish to search through. It can either be a character variable or a string of characters that you encapsulate in single (or double) quotes. Used without the back specifier the position in string of the first character not in set will be reported.

Set

Set is the group of characters that the computer uses to compare to those characters contained in string. If the back argument is absent, then the compiler will return the position in string of the first character that does not appear set. Set can either be a character variable or a group of characters that is enclosed in single (or double) quotes.

Optional Arguments

verify (string, set, back )

Back

The back argument is how one controls whether to search for the position in string of the first or last character that does not appear in set. If this argument is omitted or if back= .false. then the position of the first or leftmost character in string that does not appear in set will be reported. If back= .true. then the last or rightmost character in string that does not appear in set will be reported.

Results

When using this function keep in mind that when back is absent, it will, by default, search for the leftmost character that does not appear in set. For example, the character variable word1 is defined and then a then two searches are performed without the back specifier as follows:
		word1 = 'mississippi'
		l = verify (word1,'misp')
		n = verify(word1,'mi')
The first search will result in the value of zero being stored in l. The reason why l will equal zero is because all four letters in the search set appear in word1. This result would have been the same with back specifier present. The result of the second search will be the number three being stored in n. The same thing would be returned if the back specifier was set to .false. However, if back had been present and set equal .true. then the results would have been different. In this line of code:
		n = verify(word1,'mi',back=.true.)
The value of ten would be stored in n. This corresponds to the rightmost position in word1 of the character that is not m or i.

For more information and examples see

examples charvr90.f and tadj.f

lecture twenty five

Up one level / Home


Written by Jason Wehr : jcw142@psu.edu and Maintained by John Mahaffy : jhm@cac.psu.edu