Here's one way to do it:
D InpFld s 256a Inz( 'MR. SANTA CLAUS' )
D ChrStr s 257a Varying
D ChrAry s Like( InpFld ) Dim( 64 )
D ChrFld s Like( InpFld )
D Blank s 1a
D Ix s 5u 0
D Ic s 5u 0
D Pb s 5u 0
D Pe s 5u 0
D Hi c 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
D Lo c 'abcdefghijklmnopqrstuvwxyz'
C Eval ChrStr = %TrimR( InpFld ) + Blank
C Blank Check ChrStr Pb
C DoW %Found
C Blank Scan ChrStr: Pb Pe
C Eval Ix = Ix + 1
C Eval ChrAry(Ix) = %SubSt( ChrStr: Pb: Pe-Pb )
C Blank Check ChrStr: Pe Pb
C Clear ChrStr
C Do Ix Ic
C Hi:Lo Xlate ChrAry(Ic):2 ChrFld
C Eval ChrStr = ChrStr + ' ' + %TrimR( ChrFld )
C Eval InpFld = %SubSt( ChrStr: 2 )
As an Amazon Associate we earn from qualifying purchases.
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.