OVRLAY: Overlaying a Character String (Maintain)

How to:

The OVRLAY function overlays a base character string with a substring.

To use this function, you must import the function library MNTUWS. For information on importing this library, see Accessing and Calling a Function.

There is also an OVRLAY function available for the reporting language. For information on this function, see Character Functions.


Top of page

x
Syntax: How to Overlay a Character String
OVRLAY(string1, string2, position)

where:

string1

Alphanumeric

Is the base character string.

string2

Alphanumeric

Is the substring that will overlay string1.

position

Integer

Is the position in the base string at which the overlay begins.



Example: Overlaying a Character String

OVRLAY replaces the letters MCA in the MOVIECODE field with MHD:

MAINTAIN FILE movies 
Module Import (mntuws);
Case Top
Infer moviecode into MCASTK
Compute MCASTK.NEWCODE/A6;
For all next Moviecode into stk1
Stack copy from stk1 into MCASTK
  where moviecode contains 'MCA'; 
Compute i/i2=1;
Type "Original Code   New Code"
repeat mcastk.Foccount
  Compute MCASTK(i).Newcode = OVRLAY(MCASTK(I).MOVIECODE, 'MHD', 4);
  Type " <<MCASTK(i).moviecode          <<MCASTK(I).NEWCODE"
  Compute i=i+1;
endrepeat
EndCase
END

The following are sample values for MOVIECODE and the values for the result of the OVRLAY function:

  Original Code   New Code
  001MCA          001MHD
  081MCA          081MHD
  082MCA          082MHD
  161MCA          161MHD
  196MCA          196MHD
  530MCA          530MHD
  550MCA          550MHD
  883MCA          883MHD

WebFOCUS