Fair enough. I guess we need to protect ourselves from leading zero numeric
strings. In that case, this should work:
MACRO
ACLEAR &L=,&A=VSAMWORK,&I=00
LCLC &AA
LCLA &LEN
AIF (T'&L EQ 'O' OR T'&L NE 'N').AROUND NO VALID LENGTH?
&LEN SETA &L
AIF (&LEN GT 256).DOLIT WE NEED TO LOAD A LITERAL
LA R15,&LEN NUMBER OF BYTES TO CLEAR
AGO .CONTINU CONTINUE WITH MAINLINE CODE
.DOLIT ANOP
SR R15,R15 CLEAR LENGTH REGISTER
ICM R15,B'0011',=AL2(&LEN) GET LENGTH
AGO .CONTINU
.AROUND ANOP .
&AA SETC 'L''' MAKE LENGTH ATTRIBUTE STRING
LA R15,&AA&A GET LENGTH OF FIELD
.CONTINU ANOP . LENGTH IS SET
LA R14,&A TARGET ADDRESS TO CLEAR
LR R0,R14 SOURCE ADDRESS TO CLEAR
SR R1,R1 SET SENDING FIELD LENGTH TO ZERO
IC R1,X'&I' SET PAD CHARACTER
MVCL R14,R0 INITIALIZE WORK AREA
* R0, R1, R14, AND R15 ARE NOW FUBAR
MEND
TESTMAC CSECT , SET &SYSECT
USING *,R15 R15 ALREADY SET FROM CALLER
ACLEAR
ACLEAR L=0000010
ACLEAR L=20
ACLEAR L=500
VSAMWORK DS CL500
YREGS
LTORG , <= JUST TO BE KOSHER
*
END TESTMAC END ASSEMBLY, SUPPLY EP
Everything is all in CAPS because "CAPS ON" is my default setting for
SPF/PC. I tend to prefer it that way. Old habits die hard.
-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]]
On Behalf Of John Gilmore
Sent: Saturday, August 04, 2012 12:12 PM
To: [email protected]
Subject: Re: Attributes Test In Macros
Dan Skomsky suggests the statement
| AIF ('&L' GT '256').DOLIT WE NEED TO LOAD A LITERAL
which is booby trapped. The HLASM and its predecessors compare
strings lexicographically iff their lengths|character counts are
equal. When they are not, the longer compares greater than the
shorter. Thus 'aaa' < 'aab' but 'aa' > 'x' and, for example, '0000' >
'256'.
Arithmetic with strings should be attempted only by the very
experienced and then only using normalized|standardized forms.
I also note in passing that all of you are using only uppercase
letters/majuscules in your source statements. Why?
John Gilmore, Ashland, MA 01721 - USA