VERIFY

VERIFY returns an unscaled REAL FIXED BINARY value that indicates the position in x of the leftmost character, widechar, graphic, or bit that is not in y. It also allows you to specify the location within x at which to begin processing.

If all the characters, widechars, graphics, or bits in x do appear in y, a value of zero is returned. If x is the null string, a value of zero is returned. If x is not the null string and y is the null string, the value of n is returned. The default value for n is one.
Read syntax diagramSkip visual syntax diagram
>>-VERIFY(x,y-+----+-)-----------------------------------------><
              '-,n-'     

x
String-expression.
y
String-expression.
n
Expression n specifies the location within x where processing begins. It must have a computational type and is converted to FIXED BINARY(31,0).

Unless 1 ≤ n ≤ LENGTH(x) + 1, the STRINGRANGE condition, if enabled, is raised. Its implicit action and normal return give a result of 0. If n = LENGTH(x) + 1, the result is zero.

The BIFPREC compiler option determines the precision of the result returned.

VERIFY will perform best when the second and third arguments are either literals, named constants declared with the VALUE attribute, or restricted expressions.

Example

  X = '  a  b';         /* Two blanks in each space */
  Y = ' ';              /* One blank                */
  N = 1;
  I = verify(X,Y,N);    /* I = 3 */

  do while (I > 0);
    display ( 'Nonblank at position ' ∥ trim(I) );
    N = I + 1;
    I = verify(X,Y,N);
  end;

After the first pass through the do-loop, N=4 and VERIFY(X,Y,N) returns 6. After the second pass, N=7 (LENGTH(x)+1), VERIFY(X,Y,N) now returns 0, and the loop ends.

For more examples of the VERIFY built-in function, see SEARCH.






Published: 23 December 2018