!**********************************************************************
!*       Replace Characters in String                                 *
!**********************************************************************
!*                                                                    *
!*        INPUT: $I_string  - Input String                            *
!*               $I_old     - Old Characters (Obsolete)               *
!*               $I_new     - New Characters (Replacement)            *
!*       OUTPUT: $O_string  - Output String (Characters Replaced)     *
!*                                                                    *
!*               To de-activate this function:                        *
!*               #define REPL_Func_Remove                             *
!*                                                                    *
!**********************************************************************
!*                                                                    *
!*      EXAMPLE: let $I_string = 'where a.emplid = b.emplid'          *
!*               do REPL-Func($I_string, 'a.', 'JOB.', $O_sql1)       *
!*               do REPL-Func($I_string, 'emplid', 'custid', $O_sql2) *
!*               do REPL-Func('A1A2A3', 'A', 'Z', $O_string)          *
!*                                                                    *
!*      RESULTS: $O_sql1   = 'where JOB.emplid = b.emplid'            *
!*               $O_sql2   = 'where a.custid = b.custid'              *
!*               $O_string = 'Z1Z2Z3'                                 *
!*                                                                    *
!**********************************************************************
#ifndef REPL_Func_Remove
begin-procedure REPL-Func($I_string, $I_old, $I_new, :$O_string)
let $O_string        = ''
let #len             = length($I_string)
let #adj             = length($I_old)
let #old             = 1
let #new             = 0
while #new           < #len
   let #new          = instr($I_string, $I_old, #old)
   if  #new          = 0
       let #new      = #len + 1
   end-if
   if  #old          < #new
       let $O_string = $O_string || substr($I_string, #old, #new - #old)
   end-if
   if  #new          < #len
       let $O_String = $O_string || $I_new
       let #old      = #new + #adj
   end-if
end-while
end-procedure
#endif
!**********************************************************************
                                                                               
     |