TAA Tools
RMVCHAR         REMOVE CHARACTER                       TAACLRM

The  RMVCHAR  command  is similar  to  the  RPG  IV  %TRIMx  functions.
Unlike  %TRIMx,  RMVCHAR  allows  you  to remove  specified  characters
anywhere  in a string of up to 1000  bytes.  The length of the returned
value may also be returned.

A typical series of commands would be:

             DCL        &INP *CHAR LEN(25)
             DCL        &RTNVAL *CHAR LEN(1000)
             DCL        &RTNLEN *DEC LEN(5 0)
              .
             RMVCHAR    INPVAL(&INP) RMVCHAR('&#') RTNVAL(&RTNVAL) +
                          RTNLEN(&RTNLEN)

The default is to trim leading blanks.

If the &INP value  was ' &#ABC& ', the  RTNVAL would be 'ABC' (in  1000
bytes) with a RTNLEN of 3.

If the &INP value  was ' &#AB&C& ', the RTNVAL would  be 'ABC' (in 1000
bytes) with a RTNLEN of 3.

If  the &INP value was '  &&& ', the RTNVAL would  be all blanks with a
RTNLEN of 0.

Difference with RPG %TRIMx built-in function
--------------------------------------------

The RPG  IV  %TRIM function  definition does  not  trim data  from  the
middle of  a string.   Trimming  stops (at either  end) when  the first
character  is  encountered   that  does  not  match  one  of  the  trim
characters specified.

There  is  no  concept  of  removing  trailing  blanks  with   RMVCHAR.
Because a large  variable must be  specified for the  RTNVAL parameter,
there will  almost always be blanks  at the end.   The RTNLEN parameter
may be used to describe the length.

Difference with TRIM TAA command
--------------------------------

The  TRIM TAA  command definition does  not remove  any characters from
the middle  of  a string.   Trimming  stops (at  either  end) when  the
first  character is encountered  that does  not match  one of  the trim
characters  specified.   Using  TRIM instead  of RMVCHAR  as previously
shown:

             TRIM       INPVAL(&INP) TRIMCHAR('&#') RTNVAL(&RTNVAL) +

                          RTNLEN(&RTNLEN)

If the &INP value was  ' &#ABC& ', the RTNVAL  would be 'ABC' (in  1000
bytes) with a RTNLEN of 3 (same result as with RMVCHAR).

If the  &INP value  was '  &#AB&C& ',  the RTNVAL  would be 'AB&C'  (in
1000  bytes) with  a RTNLEN  of 4 (the  '&' would  be removed  from the
middle of the string as well).

RMVCHAR escape messages you can monitor for
-------------------------------------------

      TAA9891    The INPVAL value may not be all blanks.
      TAA9892    The RMVCHAR value may not be all blanks.

Escape messages from based on functions will be re-sent.

Command parameters                                    *CMD
------------------

   INPVAL        The value  to remove  specified characters  from.   It
                 may be up to 1000 bytes and may not be all blanks.

   RMVCHAR       Up to  50  characters to  be removed  from the  INPVAL
                 value.  The value cannot be all blanks.

                 All  characters entered  (designated by  the rightmost
                 non-blank)  are compared against  each position in the
                 INPVAL  value.    It  is  not  an  error  to  enter  a
                 character that does not exist in the INPVAL value.

                 It  is  not  an  error  to enter  the  same  character
                 multiple   times   such  as   '-%-',   but  additional
                 overhead is required.

                 Embedded blanks  may  be  trimmed  out,  but  a  blank
                 coded  in EBCDIC  must  be  embedded in  the  TRIMCHAR
                 value.   For example, '& #'  would eliminate '&', '#',
                 and any  embedded  blanks.   The  TRMLDGBLK  parameter
                 determines whether any leading blanks are trimmed.

                 The value  may be  entered in  Hex.   For example,  to
                 remove only  an embedded blank,  enter RMVCHAR(X'40').

   RTNVAL        The  return  value  without  the  specified characters
                 and leading  blanks (assuming  TRMLDGBLK =  *YES).   A
                 variable  must be  specified and  it must  be declared
                 as *CHAR LEN(1000).

   RTNLEN        The   return  length  (the  length   of  the  returned
                 value).  This is an  optional return variable that  if
                 used must be declared as *DEC LEN(5 0).

   TRMLDGBLK     A *YES/*NO value  for whether to trim  leading blanks.
                 *YES  is the  default to  trim  any leading  blanks at
                 the beginning of the INPVAL value.

                 *NO may be specified to retain leading blanks.

Restrictions
------------

Because the command  returns variables,  it may  only be used  in a  CL
program.

Prerequisites
-------------

The following TAA Tools must be on your system:

     SNDESCINF       Send escape information
     SNDESCMSG       Send escape message

Implementation
--------------

None, the tool is ready to use.

Objects used by the tool
------------------------

   Object        Type    Attribute      Src member    Src file
   ------        ----    ---------      ----------    ----------

   RMVCHAR       *CMD                   TAACLRM       QATTCMD
   TAACLRMC      *PGM       CLP         TAACLRMC      QATTCL
					

Added to TAA Productivity tools August 15, 2005


Home Page Up to Top