3

I have this code:

inspect w-string1 replacing all x'C48D' by 'c'

But I got this error by compiler

Operand has wrong size

Is there any solution how to replace more chars by one char thru inspect command. Or I must do it by myself via perform loop?

Pavel Matras
  • 329
  • 1
  • 5
  • 13
  • 1
    `INSPECT ... REPLACING` only replaces with the same length. But you can use a simple `MOVE` when you one-time code an user defined function for the replacing. ... or use a different compiler which has something like `FUNCTION SUBSTITUTE` in already (GnuCOBOL does). – Simon Sobisch May 15 '17 at 18:58

1 Answers1

3

When using the INSPECT statement, both strings must be the same length. The only way to replace multiple characters by a different number of characters is to write your own loop to do it.

SaggingRufus
  • 1,814
  • 16
  • 32
  • Hard to imagine why this is not a standard function! The people who put the standards must be out of touch with this planet! – NoChance Jul 07 '21 at 21:55