View previous topic :: View next topic
|
Author |
Message |
Pankaj Shrivastava Currently Banned New User
Joined: 24 Jul 2009 Posts: 51 Location: Pune
|
|
|
|
Hi ,
Is there any way we can avoid declaring a table of 256 byte in TRT when i need to check a byte for Numeric only .
thanks |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You can check the one-byte (using a CLI) for a value not less than X'F0' (C'0') and not greater than X'F9' (C'9').
I'm assuming you're talking about display-numeric data and not packed-decimal data?
Is this CICS/Assembler?
Bill |
|
Back to top |
|
|
Pankaj Shrivastava Currently Banned New User
Joined: 24 Jul 2009 Posts: 51 Location: Pune
|
|
|
|
Hi Bill ,
I have to go for TRT , sorry my question appeared as if i have one byte only ..I have to check each byte in a string for numeric . i.e I have 20 byte of string and need to check if is pure numeric .
Thanks |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Define your table as 256X'04', then ORG table+240 with XL10'00'.
If the field contains all numerics, then a CC "BZ" will be raised after the TRT.
Otherwise, R1 will contain the address of the bad-byte and R2 will contain the actual byte-value found.
Optionally, you can clear R1 and R2 to X'00's before the TRT, but it's not necessary.
Some shops have pre-defined tables, which you can bring into the program, via an MVS LOAD Macro (Batch) or CICS LOAD PROGRAM (CICS). It saves base-register addressability and allows a common table for validation, available to all programs.
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Optionally, you could use a BCT loop. R14 and R15 are used in this example and should not be a problem. R1 will contain the number of non-numeric bytes found.
Code: |
NUMERIC DS CL20
*
SLR R1,R1
LA R14,NUMERIC+L'NUMERIC-1
LA R15,L'NUMERIC
NUMLOOP EQU *
CLI 0(R14),C'0'
BL NUMFAIL
CLI 0(R14),C'9'
BNH NUMBUMP
NUMFAIL EQU *
LA R1,1(,R1)
NUMBUMP EQU *
BCTR R14,0
BCT R15,NUMLOOP
LTR R1,R1
BZ NUMGOOD
* IF THE LTR FAILS (CC IS NOT ZERO), THEN THE NUMERIC FIELD IS NON-NUMERIC
NUMGOOD EQU *
|
Bill |
|
Back to top |
|
|
Pankaj Shrivastava Currently Banned New User
Joined: 24 Jul 2009 Posts: 51 Location: Pune
|
|
|
|
Thx Bill , The code is very useful . |
|
Back to top |
|
|
|