CHKHEX CHECK HEX TAAHEXD |
The Check Hex command checks a string of hex characters such as
'C1C2C3' to ensure valid hex characters exist. A string of up to 512
characters may be checked. You must use the RTNLOC value to
determine if an error exists. CHKHEX can be helpful when a user is
entering hex characters which must be validated.
A typical series of commands would be:
DCL &RTNLOC *DEC LEN(3 0)
.
CHKHEX HEXSTRING(xxxx) RTNLOC(&RTNLOC)
IF (&RTNLOC *NE 0) DO /* Error *
.
. /* Your handling of the error */
.
ENDDO /* Error */
Note that the value to be checked assumes the user has entered at
least a 2 byte value such as 'C1'. The length of the hex string is
determined internally (can be a max of 512) and only the actual
length is checked.
An embedded blank within the string is invalid such as 'C1 C3'.
Trailing blanks are not checked. An all blank value is considered an
error.
The hex string must contain an even number of characters. For
example, 'C2C' would be invalid as it has an odd length.
Valid characters
----------------
The valid characters are:
A-F
a-f
0-9
CHKHEX escape messages you can monitor for
-------------------------------------------
TAA9891 The HEXSTRING value does not contain an
even number of characters
Escape messages from based on functions will be re-sent.
You determine if an invalid character exists by checking the RTNLOC
variable.
CHKHEX Command parameters *CMD
-------------------------
HEXSTRING The hexadecimal string to be checked. Up to 512
bytes may be entered. The length of the value is
determined and only those characters are checked.
Embedded blanks are not valid. An all blank value
is considered invalid. Trailing blanks are not
checked.
An even number of characters must be entered. A
value such as 'C1C' is invalid as it has an odd
length.
The characters entered must be between A-F, a-f, or
0-9 (X'C1' - X'C6', X'81' - X'86', or X'F0' - X'F9')
to be considered valid.
RTNLOC The return location to be checked to determine if
valid hex characters exist. This is a required
parameter that must be declared as *DEC LEN(3 0).
A value of 0 is returned if valid characters exist.
If an invalid value exists, RTNLOC describes the
position within the string where the invalid
character exists.
INVALID The invalid character found or 'blank' if a blank
(X'40') exists. This is an optional return variable
that if specified must be declared as *CHAR LEN(8).
The intent of the value is to allow a detail
explanation in your error handling of what the
invalid character is.
Restrictions
------------
Because CHKHEX returns variables, the command may only be used in a
CL program.
Prerequisites
-------------
The following TAA Tools must be on your system:
DIVIDE Divide
EDTVAR Edit variable
RTVVALA Retrieve value attribute
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
------ ---- --------- ---------- ----------
CHKHEX *CMD TAAHEXD QATTCMD
TAAHEXDC *PGM CLP TAAHEXDC QATTCL
|
Added to TAA Productivity tools July 15, 2011