TAA Tools
CHKDEC          CHECK DECIMAL                          TAACLUA

The Check  Decimal  command checks  a string  of  up to  512 bytes  for
whether  only  digits  0-9  exist.    Embedded  blanks  are  considered
invalid.   A check for  a leading and trailing  minus sign is optional.

The RTNLOC parameter  is required.   If it  is 0,  the input value  has
passed the check.

A typical series of commands would be:

             DCL       &RTNLOC *DEC LEN(3 0)
             DCL       &RTNLOCA *CHAR LEN(22)
             DCL       &INVALID *CHAR LEN(8)
              .
             CHKDEC    DECSTRING(nnnnn) RTNLOC(&RTNLOC)
                         INVALID(&INVALID)
             IF        (&RTNLOC *GT 0) DO /* Failed */
             EDTVAR    CHROUT(&RTNLOCA) NUMINP(&RTNLOC)
             SNDESCMSG MSG('CHKDEC found an invalid character +
                         at location ' *CAT &RTNLOCA +
                         *TCAT '.  Character = ' *CAT &INVALID)
             ENDDO     /* Failed */

The  INVALID parameter  is optional,  but allows  better  message text.
If  an embedded blank character is found,  the word 'blank' will appear
in the message.

A value of -0(s) is considered invalid.  A digit 1-9 must exist.

CHKDEC escape messages you can monitor for
------------------------------------------

      TAA9891    The DECSTRING value cannot be all blank
      TAA9892    The DECSTRING value cannot be a single minus sign
      TAA9893    The DECSTRING value cannot be zero(s) and a minus sign

Escape messages  from based on  functions will  be re-sent.   You  must
check the RTNLOC for a value GT 0 to sense an invalid character.

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

   DECSTRING     The string  of characters  to be  checked.   The value
                 may  be up to 512  bytes.  Leading  or embedded blanks
                 are  considered  invalid.    An  all  blank  value  is
                 considered invalid.   A  single character  of a  minus
                 sign is considered invalid.

   ALWLDGMNS     A  *YES/*NO value  for  whether a  leading  minus sign
                 may exist in the first position.

                 *NO  is the default meaning  no leading minus sign may
                 exist.

                 *YES may  be specified  to mean a  leading minus  sign
                 may exist.

   ALWTRLMNS     A  *YES/*NO value  for whether  a trailing  minus sign
                 may exist in the last position.

                 *NO  is  the default  meaning no  trailing  minus sign
                 may exist.

                 *YES may be  specified to mean  a trailing minus  sign
                 may exist.

                 If  both  ALWLDGMNS  and ALWTRLMNS  are  *YES,  and  a
                 leading minus  exists, it is considered  an error if a
                 trailing minus  also  exists and  the  last  character
                 will be flagged as invalid.

   RTNLOC        The   return   location  where   the   first   invalid
                 character  exists.   This is  a required  return value
                 that must be specified as *DEC LEN(3 0).

                 If all characters are valid, a 0 is returned.

   INVALID       An  optional  return  value that  describes  the first
                 invalid character  found.   If  the invalid  character
                 is  an  embedded  blank,  'blank'  will  be  returned.
                 This  is an  optional return  value that if  used must
                 be specified as *CHAR LEN(8).


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

None.

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

The following TAA Tools must be on your system:

     EDTVAR          Edit variable
     RTVVALA         Retrieve variable attributes
     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
   ------        ----    ---------      ----------    ----------

   CHKDEC        *CMD                   TAACLUA       QATTCMD
   TAACLUAC      *PGM       CLP         TAACLUAC      QATTCL
					

Added to TAA Productivity tools July 15, 2012


Home Page Up to Top