Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Adding one to a HEX number

460 views
Skip to first unread message

Ed. Benoit

unread,
Jan 6, 2004, 12:50:12 PM1/6/04
to
Hi List,
Do anyone have an example in CLIST or REXX, I perfer CLIST on how to add 1 to
a Hexadecimal number?

Thanks,
Ed.

Stephen E. Bacher

unread,
Jan 6, 2004, 1:08:51 PM1/6/04
to
"Ed. Benoit" <Ibm...@aol.com> wrote:

>Do anyone have an example in CLIST or REXX, I perfer CLIST on how to add 1 to
>a Hexadecimal number?

The simplest (though probably not the fastest) way would be to convert
the number to decimal, add 1, and convert the result back to hexadecimal.

That may sound like overkill, but not if you've already got CLIST code
that does conversion but not arithmetic. I wrote a hex converter CLIST
a long time ago, which I can post if there's interest.

For basic hexadecimal arithmetic, I wrote a PL/1 program to do that
interactively.

- seb

Binyamin Dissen

unread,
Jan 6, 2004, 1:13:37 PM1/6/04
to
On Tue, 6 Jan 2004 12:40:40 EST "Ed. Benoit" <Ibm...@AOL.COM> wrote:

:>Do anyone have an example in CLIST or REXX, I perfer CLIST on how to add 1 to
:>a Hexadecimal number?

Do it the easy way.

Convert it to decimal.

--
Binyamin Dissen <bdi...@dissensoftware.com>
http://www.dissensoftware.com

Director, Dissen Software, Bar & Grill - Israel

Rob Zenuk

unread,
Jan 6, 2004, 1:22:26 PM1/6/04
to
/* rexx hexadd1 */
say d2x(x2d(arg(1))+1)

==> hexadd1 F

10


Hope This Helps,

Rob

Ryerse, Robin

unread,
Jan 6, 2004, 2:02:48 PM1/6/04
to
First off, be very sure you understand the exact format of value to be
incremented and the format you want the result to be. If the result is
going to be subjected to further arithmetic operations, you should make it a
decimal regardless of rexx or clist.

Rob Zenunk's response is right only if the source is in ebcdic representaion
of the hex number
The correct algorithm if the source is in non-ebcedic format: return
d2c(c2d(arg(1)+1))

Rob Zenuk

unread,
Jan 6, 2004, 3:20:46 PM1/6/04
to
Yup! A more complete example to deal with either case.

/* rexx - hexadd1 */
a = 'F' /* EBCDIC characters */
b = 'F'x /* input is hex/binary */
say a '=' d2x(x2d(a)+1)
say b '=' d2c(c2d(b)+1) '=' c2x(d2c(c2d(b)+1))

===> hexadd1

F = 10
: = : = 10


Rob

Ed. Benoit

unread,
Jan 6, 2004, 3:21:06 PM1/6/04
to
Lets say I have a six byte hex number 000063BD9026 in a clist. How do I
convert it to decimal and then convert it back to hex after I have added 1 to it.
An example would be great.
Thanks, Ed.

Stephen E. Bacher

unread,
Jan 6, 2004, 3:52:48 PM1/6/04
to

Ed,

Can we limit the size of the number to 4 bytes? Otherwise we get into
arbitrary-precision arithmetic, and my code is limited to what a CLIST
can handle: fullword integer arithmetic.

Here's my whole conversion CLIST. It's designed so that someone can run it
from the TSO command line interactively, but also so that someone can
invoke it nested from another CLIST to return a converted value.

Hope this is helpful.

- seb

--- cut here ---
PROC 0 MODE() HEXNO() DECNO() NEST(&SYSNEST.)
GLOBAL GBLH GBLD /* FOR PASSING VALUES TO AND FROM A CALLING CLIST */
SET RETADDR=
IF &STR(&GBLH)^= && &STR(&HEXNO)= THEN SET HEXNO=&STR(&GBLH)
IF &STR(&GBLD)^= && &STR(&DECNO)= THEN SET DECNO=&STR(&GBLD)
CONTROL NOFLUSH NOMSG NOCAPS
ERROR DO
SET SAVECC=&LASTCC
IF &RETADDR= THEN DO
ERROR OFF
WRITE
WRITE HEX005: Unanticipated error - LASTCC = &SAVECC
WRITE
EXIT C(&SAVECC) Q
END
IF (&SAVECC=872 | &SAVECC=832) && &RETADDR=WD THEN +
WRITE *** Overflow: Value entered is too large - Conversion failed ***
ELSE IF &SAVECC>=800 && &SAVECC<=868 && &RETADDR=WD THEN +
WRITE Invalid arithmetic expression, &NRSTR(&DECNO)
ELSE DO
WRITE
WRITE *** HEX CLIST - Unanticipated error - LASTCC = &SAVECC
END
IF &NEST=YES THEN EXIT C(&SAVECC) Q
GOTO &RETADDR
END
IF &STR(&DECNO)^= && &STR(&HEXNO)^= THEN DO
WRITE HEX006: Conflicting operands entered
EXIT C(12) Q
END
IF &STR(&NEST&HEXNO&DECNO)=YES THEN DO
WRITE HEX007: Missing numeric operand
EXIT C(12) Q
END
IF &STR(&HEXNO)^= THEN GOTO HD
IF &STR(&DECNO)^= THEN GOTO DH
DO WHILE &STR(&MODE)^=DH && &STR(&MODE)^=HD
WRITENR HEX001: Enter mode - DH for decimal to hex, HD for hex to decimal
READ MODE
SET MODE = &STR(&SYSCAPS(&MODE))
END
GOTO &MODE
/*************************************/
/* Decimal to hex conversion routine */
/*************************************/
DH:+
SET RETADDR=WD
IF &STR(&DECNO)= THEN DO
WD:WRITENR Enter decimal #, END, or X to switch mode ==>
DREAD:READ
SET DECNO=&STR(&SYSCAPS(&NRSTR(&SYSDVAL)))
IF &STR(&DECNO)=END THEN EXIT
IF &STR(&DECNO)=X THEN DO
SET DECNO=
SET HEXNO=
GOTO HD
END
END
IF &STR(&DECNO)=&STR(-2147483648) THEN DO
SET HEXNO=80000000
GOTO HEXOUT
END
IF &DATATYPE(&DECNO)=CHAR THEN DO
IF &NEST=YES THEN DO
WRITE HEX002: &DECNO not a numeric integer
EXIT C(12) Q
END
WRITENR &DECNO not a numeric integer - reenter ==>
GOTO DREAD
END
IF (&DECNO)<0 THEN DO
SET SIGN=N
SET DECNO=-((&DECNO)+1)
SET N=8
END
ELSE DO
SET SIGN=P
SET RESULT=0
SET N=0
DO WHILE &RESULT<=(&DECNO) && &N<8
SET N=&N+1
IF &N<8 THEN SET RESULT=16**&N
END /* N equals the number of places in the hex result */
END
SET HEXNO=
DO WHILE &N>0
SET N=&N-1
SET RESULT=(&DECNO)/(16**&N)
IF &SIGN=N THEN SET RESULT=15-&RESULT
SET HEXNO=&STR(&HEXNO)&SUBSTR(&RESULT+1,0123456789ABCDEF)
SET DECNO=(&DECNO)//(16**&N)
END
HEXOUT:+
IF &NEST=YES THEN DO
SET GBLH=&STR(&HEXNO)
EXIT C(0)
END
WRITE Hex: ===> &HEXNO
SET HEXNO=
GOTO WD
/*************************************/
/* Hex to decimal conversion routine */
/*************************************/
HD:+
SET RETADDR=WH
IF &STR(&HEXNO)= THEN DO
WH:WRITENR Enter hex #, END, or X to switch mode ==>
HREAD:READ
SET HEXNO = &STR(&SYSCAPS(&NRSTR(&SYSDVAL)))
IF &STR(&HEXNO)=END THEN EXIT
IF &STR(&HEXNO)=X THEN DO
SET DECNO=
SET HEXNO=
GOTO DH
END
END
SET L=&LENGTH(&STR(&HEXNO))
IF &L=0 THEN GOTO WH
IF &L>8 THEN DO
IF &NEST=YES THEN DO
WRITE HEX003: Hex number exceeds maximum of 8 characters
EXIT C(12) Q
END
WRITENR Hex # cannot exceed 8 positions - reenter ==>
GOTO HREAD
END
SET SIGN=P
IF &L=8 THEN IF &SUBSTR(1,&HEXNO)>=8 | &SUBSTR(1,&HEXNO)<=F THEN +
SET SIGN=N
SET N=&L
SET DECNO=0
DO WHILE &N>0
SET N=&N-1
SET X=&SUBSTR(&L-&N,&HEXNO)
IF &STR(&X)=A THEN SET X=10
ELSE IF &STR(&X)=B THEN SET X=11
ELSE IF &STR(&X)=C THEN SET X=12
ELSE IF &STR(&X)=D THEN SET X=13
ELSE IF &STR(&X)=E THEN SET X=14
ELSE IF &STR(&X)=F THEN SET X=15
ELSE IF &STR(&X)<0 THEN DO
IF &NEST=YES THEN DO
WRITE HEX004: Invalid hex number, &HEXNO
EXIT C(12) Q
END
WRITENR Invalid hex number, &HEXNO - reenter ==>
GOTO HREAD
END
IF &SIGN=N THEN SET X=15-&X
SET DECNO=&DECNO+&X*(16**&N)
END
IF &SIGN=N THEN SET DECNO=-&DECNO-1
ELSE SET DECNO=&STR(+&DECNO)
IF &NEST=YES THEN DO
SET GBLD=&STR(&DECNO)
EXIT C(0)
END
WRITE Decimal: ===> &DECNO
SET DECNO=
GOTO WH
--- ereh tuc ---

Ryerse, Robin

unread,
Jan 6, 2004, 3:54:17 PM1/6/04
to
... now for the verified version (my original was wrong)

/* Rexx Show how to add hexadecimal 1 to a value.
Herein a meaningless series of 2 byte values are adjusted */
a_value = 'abcdJKLM0123'
do byte# = 1 to length(a_value)-1
say plus1(substr(a_value,byte#,2))
end

exit

plus1: return d2c(c2d(arg(1))+1)

Peter Vander Woude

unread,
Jan 6, 2004, 4:02:23 PM1/6/04
to
Ed,

You would code as follows:

/* rexx */

a="000063BD9026"
b=d2x(x2d(a)+1)
say b
exit

Peter I. Vander Woude

Sr. Mainframe Engineer
Harris Teeter, Inc.

>>> Ibm...@AOL.COM 01/06/2004 3:13:34 PM >>>

Ed. Benoit

unread,
Jan 6, 2004, 5:08:11 PM1/6/04
to
In a message dated 1/6/2004 1:15:27 PM Pacific Standard Time,
pwo...@HARRISTEETER.COM writes:
Peter
Would your code work in a clist? I am not a rexx person.

Ed. Benoit

unread,
Jan 6, 2004, 5:08:18 PM1/6/04
to
Can anything be done in a clist, I am not a rexx person.
Ed.

Dave Salt

unread,
Jan 6, 2004, 6:35:04 PM1/6/04
to
Ed:

You could always call a REXX program from your CLIST to perform the function
you want. The REXX program can go in the same library as the CLIST. For
example, if your CLIST is called MYCLIST and the REXX program is called
MYREXX, the CLIST logic would look something like this:

PROC 0
lots of clist stuff...
SET &HEXVALUE = &STR(62AF)
ISPEXEC VPUT (HEXVALUE) SHARED
ISPEXEC SELECT CMD(%MYREXX)
ISPEXEC VGET (HEXRES) SHARED
more clist stuff....

and the REXX program would look something like this:

/* REXX */
address ispexec
"VGET (HEXVALUE) SHARED"
hexres = (logic to add +1 to hexvalue goes here as shown by other people)
"VPUT (HEXRES) SHARED"
exit 0

Hope that helps!

Dave Salt
Soft-Center Solutions Inc.
http://www.soft-center.com
1-877-SoftCen
Bringing you SimpList(tm) - The easiest, most powerful way to surf a
mainframe!

>From: "Ed. Benoit" <Ibm...@AOL.COM>
>Reply-To: ISPF discussion list <ISP...@LISTSERV.ND.EDU>
>To: ISP...@LISTSERV.ND.EDU
>Subject: Re: Adding one to a HEX number

>Date: Tue, 6 Jan 2004 16:53:01 EST
>
>In a message dated 1/6/2004 1:15:27 PM Pacific Standard Time,
>pwo...@HARRISTEETER.COM writes:
>Peter

>Would your code work in a clist? I am not a rexx person.

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=dept/features&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca

Jeremy C B Nicoll

unread,
Jan 6, 2004, 6:43:31 PM1/6/04
to
In article <1d7.1798cc...@aol.com>,

It's a long time since I wrote clist code, but one approach is simply
to read that string of characters right to left and do what you'd do in
simple arithmetic:

rightmost character is "6"
"6" + 1 is "7" so replace rightmost char with "7".
There's no "carry" so stop calculating.

To do pqrst
plus uv

you work out what letter represents "t" + "v" and put it at the rh end
of your result. Then you do "s" + "u" and (if there was a carry from
t+v add that) and repeat the process.

--
Jeremy C B Nicoll - my opinions are my own.

Edwin Handschuh

unread,
Jan 6, 2004, 9:39:34 PM1/6/04
to
Ed:

If you're hell bent on having it done in CLIST (REXX would be much better),
here's one way to do it... Its not pretty, but it should work. One thing's
for sure, its going to be EXTREMELY SLOW.

Given:
0-F 0
10-FF 16 1st byte
100-FFF 256
1000-FFFF 4096 2nd byte
10000-FFFFF 65536
100000-FFFFFF 1048576 3rd byte

Sample CLIST:

/* Set up the test */
SET &HEX = &STR(1673367590) /* Decimal value of x'000063BD9026' */
/* Code */
SET &L = &LENGTH(&HEX)
SET &CNTR = &L
SET &TOTAL = 0
DO WHILE &CNTR < L

IF &CNTR = 0 THEN SET &VALUE = 0
IF &CNTR = 1 THEN SET &VALUE = 16
IF &CNTR = 2 THEN SET &VALUE = 4096
IF &CNTR = 3 THEN SET &VALUE = 1048576

SET &BYTE = &SUBSTR(&CNTR:&CNTR,&STR(&HEX)) /* Get a byte */

/* Hard code x'00' through x'FF' in the &STR( ) statements below - Use ISPF
HEX ON to key it */

IF &STR(&BYTE) = &STR( ) THEN SET &V = 0
IF &STR(&BYTE) = &STR( ) THEN SET &V = 1
......
....
.
IF &STR(&BYTE) = &STR( ) THEN SET &V = 255

SET &TOTAL = &TOTAL + &EVAL(&VALUE + &V)
END
WRITE VALUE OF HEX NUMBER = &TOTAL

No, I'm not proud of the aforementioned, but it should work. And NO, I
haven't tested it, but its close.

ETH


-----Original Message-----
From: ISPF discussion list [mailto:ISP...@LISTSERV.ND.EDU]On Behalf Of

Ed. Benoit
Sent: Tuesday, January 06, 2004 3:14 PM
To: ISP...@LISTSERV.ND.EDU
Subject: Re: Adding one to a HEX number

Ed. Benoit

unread,
Jan 6, 2004, 9:54:55 PM1/6/04
to
Need help with the rexx part.
I will call this rexx from a clist after I do a vput (hexno) shared from
the clist.. What is incorrect with these statements.
It appears it do not like the statement NHEX=D2X(X2D(&HEXNO)+1)


/* REXX */
/* HEXNO = 000063BD9026 */
ADDRESS ISPEXEC
'VGET (HEXNO) SHARED'
NHEX=D2X(X2D(&HEXNO)+1)
SAY NHEX
ADDRESS ISPEXEC
'VPUT (NHEX) SHARED'
EXIT 0

Jeremy C B Nicoll

unread,
Jan 6, 2004, 10:37:45 PM1/6/04
to
In article <41.38ae65d...@aol.com>,

Ed. Benoit <Ibm...@AOL.COM> wrote:
> Need help with the rexx part.
> I will call this rexx from a clist after I do a vput (hexno) shared from
> the clist.. What is incorrect with these statements.
> It appears it do not like the statement NHEX=D2X(X2D(&HEXNO)+1)

Take the ampersand out. rexx vars don't have ampersands in them.

Also, instead of:

> /* REXX */
> /* HEXNO = 000063BD9026 */
> ADDRESS ISPEXEC
> 'VGET (HEXNO) SHARED'
> NHEX=D2X(X2D(&HEXNO)+1)
> SAY NHEX
> ADDRESS ISPEXEC
> 'VPUT (NHEX) SHARED'
> EXIT 0

use:

/* REXX */
address ispexec

'vget (hexno) shared'
nhex = d2x(x2d(hexno)+1)
'vput (nhex) shared'
exit 0

ie you don't need to set the addressing environment twice. If it were
me I'd not use two ispf vars either, I'd just do:

/* REXX */
address ispexec

'vget (hexno) shared'
hexno = d2x(x2d(hexno)+1)
'vput (hexno) shared'
exit 0

Also if the values are small, you could dispense with the vget/vput
stuff completely and just use a commandline parm to pass the hexno into
the exec and returncode to get it back. In the clist something like:

SET HEXNUM = &STR(000ABCD)
%ADDONETO &HEXNUM
WRITE HEXNUM &HEXNUM BECAME &LASTCC

and have rexx exec ADDONETO contain:

/* REXX */
parse arg hexno .
exit d2x(x2d(hexno)+1)

Dave Salt

unread,
Jan 6, 2004, 11:18:14 PM1/6/04
to
Ed:

Remove the ampersand. Unlike CLIST, anything in REXX that's not enclosed in
quotes is considered a a variable (unless of course it's an actual REXX
statement or instruction such as IF, ELSE, D2X, +1, etc.). For example:

CLIST:
SET &FIRST = FRED
SET &LAST = SMITH
WRITE My first name is &FIRST and my last name is &LAST


REXX:
first = "FRED"
last = "SMITH"
say "My first name is "first" and my last name is "last

Both of the above produce the same results. Where it gets a bit confusing is
that when you look at the SAY statement shown above, at first glance it
looks as though "first" is enclosed in quotes. But when you look at it more
carefully, you realize it's actually outside the quotes and is therefore a
variable which REXX will resolve. Hope that helps,

Dave Salt
Soft-Center Solutions Inc.
http://www.soft-center.com
1-877-SoftCen
Bringing you SimpList(tm) - The easiest, most powerful way to surf a
mainframe!

>From: "Ed. Benoit" <Ibm...@AOL.COM>
>Reply-To: ISPF discussion list <ISP...@LISTSERV.ND.EDU>

>To: ISP...@LISTSERV.ND.EDU
>Subject: Re: Adding one to a HEX number

>Date: Tue, 6 Jan 2004 21:52:54 EST
>
>Need help with the rexx part.
>I will call this rexx from a clist after I do a vput (hexno) shared from
>the clist.. What is incorrect with these statements.
> It appears it do not like the statement NHEX=D2X(X2D(&HEXNO)+1)
>
>

>/* REXX */
>/* HEXNO = 000063BD9026 */
>ADDRESS ISPEXEC
>'VGET (HEXNO) SHARED'
>NHEX=D2X(X2D(&HEXNO)+1)
>SAY NHEX
>ADDRESS ISPEXEC
>'VPUT (NHEX) SHARED'
>EXIT 0

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca

Ed. Benoit

unread,
Jan 7, 2004, 4:01:04 AM1/7/04
to
In a message dated 1/6/2004 7:37:03 PM Pacific Standard Time,

Jer...@OMBA.DEMON.CO.UK writes:
/* REXX */
address ispexec
'vget (hexno) shared'
hexno = d2x(x2d(hexno)+1)
'vput (hexno) shared'
exit 0
Jeremy,
In my clist I make a call like:
ispexec select cmd(%rkirex01)
In the rexx routine rkirex01 I get this message
ispexec select cmd(%rkirex01)
4 +++ hexno = d2x(x2d(hexno)+1)
error running rkirex01, line 4: incorrect call to routine

Any idea what I am doing incorrect.
Thanks, Ed.

Dave Salt

unread,
Jan 7, 2004, 9:13:50 AM1/7/04
to
Ed,

Is "HEXNO" an actual hex value or a string of characters that represent a
hex value? For example, is HEXNO ".." (where ".." represents 2 unreadable
hex characters) or is it "B3B4" (i.e. a 4 character string that visually
represents 2 unreadable hex characters). For the logic to work the way it's
written, it would have to be a visual representation of a hex string string
such as "B3B4". If you want it to work using an actual (unreadable) hex
string, change the logic to this:

hexno = d2c(c2d(hexno)+1)

Hope that helps,

Dave Salt
Soft-Center Solutions Inc.
http://www.soft-center.com
1-877-SoftCen
Bringing you SimpList(tm) - The easiest, most powerful way to surf a
mainframe!

>From: "Ed. Benoit" <Ibm...@AOL.COM>
>Reply-To: ISPF discussion list <ISP...@LISTSERV.ND.EDU>
>To: ISP...@LISTSERV.ND.EDU
>Subject: Re: Adding one to a HEX number

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca

Jeremy C B Nicoll

unread,
Jan 7, 2004, 9:14:06 AM1/7/04
to
In article <f9.35e9219...@aol.com>,
Ed. Benoit <Ibm...@AOL.COM> wrote:

> Jeremy,
> In my clist I make a call like:
> ispexec select cmd(%rkirex01)

in uppercase presumably?

> In the rexx routine rkirex01 I get this message
> ispexec select cmd(%rkirex01)

> 4 +++ hexno = d2x(x2d(hexno)+1)
> error running rkirex01, line 4: incorrect call to routine

> Any idea what I am doing incorrect.

No, because that statement looks right and works ok here. If it
doesn't work it probably means that the hexno variable doesn't contain
what I'd expect it to. What do you see if in your rexx exec you put
something like

say ">>"hexno"<<"

just before the failing statement? You should see a hex string of
numbers enclosed in >> and <<, eg:

>>00ABCD<<

But if you see >>00ABCD << for example then hexno is a string with a
trailing blank and that won't work. If this exec is using the vget
method to find the incoming hexno value then maybe it wasn't vput
properly by the clist - get the clist to write out the value it is
passing too and see if they are the same.


> Thanks, Ed.

Ed. Benoit

unread,
Jan 7, 2004, 11:05:20 AM1/7/04
to
I do a say hexno before I do HEXNO=D2X(X2D(HEXNO)+1)
and the value is 000063bd9027 as showned on the following error.
Do I need something special to execute a rexx from a sysproc dataset. I must
be missing something silly because I do not know REXX but after this problem
is resolved I will get every rexx book I can lay my hands on. I copied and
pasted the error that I get.

SET RC = 0
ISPEXEC SELECT CMD(%RKIREX01)
000063BD9026
5 +++ HEXNO=D2X(X2D(HEXNO)+1)
Error running RKIREX01, line 5: Incorrect call to routine
SET RC = 20040
ISPEXEC VGET (HEXNO) SHARED
SET RC = 0
SET SRBA = 000063BD9026
SET RC = 0
EXIT

Any help would be appreciated.
Ed.

Ed. Benoit

unread,
Jan 7, 2004, 12:19:53 PM1/7/04
to
First allow me to give thanks to all for all the help in the last two days.
The last problem was resolved with the numeric digits(15). My hexno was
000063bd9026 after adding 1 it came back 63bd9027, so it worked. Now is there a
way for me to keep the leading zeroes in the hex number?

Ed.

Brad Taylor

unread,
Jan 7, 2004, 12:07:42 PM1/7/04
to
What I usually do in situations like this is in your rexx exec after the /* rexx */
add a line with

trace ?r

This will turn on interactive trace. each time you press enter it will execute one instruction.
you can dynamically enter rexx commands, I usually just do says. For example say hexno to see the value of hexno
say x2d(hexno) to see what x2d produces. sometimes the length of the rexx variable is important, so after the vget
you can enter say Length(hexno) to see how long it is, leading or trailing blanks. you can use hexno = strip(hexno) to
remove leading and trailing blanks.

You can also split your statements into seperate statements to help determine what is wrong, for example

say "hexno="hexno
y = x2d(hexno)
say "y="y
y = y + 1
say "y="y
hexno = d2x(y)
say "hexno="hexno


hth

-----Original Message-----
From: ISPF discussion list [mailto:ISP...@LISTSERV.ND.EDU]On Behalf Of
Ed. Benoit

Sent: Wednesday, January 07, 2004 9:58 AM
To: ISP...@LISTSERV.ND.EDU
Subject: Re: Adding one to a HEX number

BUDBILL, GENE

unread,
Jan 7, 2004, 12:11:24 PM1/7/04
to
Try adding the statement:

NUMERIC DIGITS(15)

to your EXEC.

Gene

Ed.

BUDBILL, GENE

unread,
Jan 7, 2004, 12:13:30 PM1/7/04
to
I should provide explanations with answers. The NUMERIC DIGITS
statement controls precision.

NUMERIC DIGITS

controls the precision to which arithmetic operations and arithmetic

built-in functions are evaluated. If you omit expression1, the

precision defaults to 9 digits. Otherwise, expression1 must evaluate

to a positive whole number and must be larger than the current
NUMERIC
FUZZ setting.

There is no limit to the value for DIGITS (except the amount of

storage available), but note that high precisions are likely to

require a good deal of processing time. It is recommended that you
use
the default value wherever possible.

My little sample driver:

/* REXX */
TRACE I
NUMERIC DIGITS(15)
HEXNO=00063BD9027
HEXNO=D2X(X2D(HEXNO)+1)
SAY HEXNO

The results (on this system) are:

3 *-* NUMERIC DIGITS(15)
>L> "15"
4 *-* HEXNO=00063BD9027
>L> "00063BD9027"
5 *-* HEXNO=D2X(X2D(HEXNO)+1)
>V> "00063BD9027"
>F> "1673367591"
>L> "1"
>O> "1673367592"
>F> "63BD9028"
6 *-* SAY HEXNO
>V> "63BD9028"
63BD9028
***

Seibert, Dave

unread,
Jan 7, 2004, 1:04:40 PM1/7/04
to
Hello Ed,

There's no way to preserve them, but you can use the Right function to
put them back -- by padding the number on the left.

hexno = right(hexno,12,'0')

>>--Right(string,length---------------)--------><
Ś Ś
--,pad--
returns a string of length length, containing the rightmost characters
of string. The string is padded with pad characters on the left as
needed(or truncated). The default pad char. is blank.

Dave


-----Original Message-----
From: ISPF discussion list [mailto:ISP...@LISTSERV.ND.EDU]On Behalf Of
Ed. Benoit
Sent: Wednesday, January 07, 2004 12:18 PM
To: ISP...@LISTSERV.ND.EDU
Subject: Re: Adding one to a HEX number

Ed.

The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it.

Rob Zenuk

unread,
Jan 7, 2004, 12:59:43 PM1/7/04
to
In a message dated 1/7/2004 10:18:43 AM US Mountain Standard Time,

Ibm...@AOL.COM writes:
Now is there a
way for me to keep the leading zeroes in the hex number?
NHEX=right(D2X(X2D(&HEXNO)+1),12,0)

Rob

Brad Taylor

unread,
Jan 7, 2004, 12:58:57 PM1/7/04
to
hexno = Right("000000000000"||hexno,12) for a 12 character value with leading zeroes

-----Original Message-----
From: ISPF discussion list [mailto:ISP...@LISTSERV.ND.EDU]On Behalf Of
Ed. Benoit
Sent: Wednesday, January 07, 2004 11:18 AM
To: ISP...@LISTSERV.ND.EDU
Subject: Re: Adding one to a HEX number


First allow me to give thanks to all for all the help in the last two days.
The last problem was resolved with the numeric digits(15). My hexno was

000063bd9026 after adding 1 it came back 63bd9027, so it worked. Now is there a


way for me to keep the leading zeroes in the hex number?

Ed

BUDBILL, GENE

unread,
Jan 7, 2004, 1:03:39 PM1/7/04
to
No, but you can put them back on the number. Try

HEXNO=RIGHT(HEXNO,14,"0")

Where you specify the total number of characters you want (14 in this
case) and the character you want added if there are not enough
characters available.

Gene

-----Original Message-----
From: ISPF discussion list [mailto:ISP...@LISTSERV.ND.EDU] On Behalf Of
Ed. Benoit
Sent: Wednesday, January 07, 2004 9:18 AM
To: ISP...@LISTSERV.ND.EDU
Subject: Re: Adding one to a HEX number


First allow me to give thanks to all for all the help in the last two
days. The last problem was resolved with the numeric digits(15). My
hexno was 000063bd9026 after adding 1 it came back 63bd9027, so it
worked. Now is there a way for me to keep the leading zeroes in the hex
number?

Ed.

Dave Salt

unread,
Jan 7, 2004, 1:19:49 PM1/7/04
to
To add leading zeroes, right justify the number. For example:

hexno = right(hexno,12,0)

This creates a 12 digit number that is padded on the left with zeroes. HTH,

Dave Salt
Soft-Center Solutions Inc.
http://www.soft-center.com
1-877-SoftCen
Bringing you SimpList(tm) - The easiest, most powerful way to surf a
mainframe!

>From: "Ed. Benoit" <Ibm...@AOL.COM>
>Reply-To: ISPF discussion list <ISP...@LISTSERV.ND.EDU>

>To: ISP...@LISTSERV.ND.EDU
>Subject: Re: Adding one to a HEX number
>Date: Wed, 7 Jan 2004 12:17:41 EST
>
>First allow me to give thanks to all for all the help in the last two days.
>The last problem was resolved with the numeric digits(15). My hexno was
>000063bd9026 after adding 1 it came back 63bd9027, so it worked. Now is
>there a
>way for me to keep the leading zeroes in the hex number?
>
>Ed.

_________________________________________________________________

Ed. Benoit

unread,
Jan 7, 2004, 2:19:11 PM1/7/04
to
Hello List,
Thanks again to all for pulling me out of the hole. Everything is working
now. I will get any REXX books I can get my hands on. Any basic books I should
start with and where to get them would be appreciated.

Many Thanks, Thanks, Thanks,
Ed.

Rob Zenuk

unread,
Jan 7, 2004, 3:03:21 PM1/7/04
to
Good "free" books available on the public Internet.

z/OS V1R2.0 TSO/E REXX User's Guide

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4C310/CCONTENTS?
SHELF=IKJ4BK20&DN=SA22-7791-01&DT=20010706113306

z/OS V1R3.0 TSO/E REXX Reference

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IKJ4A320/CCONTENTS?
SHELF=IKJ4BK20&DN=SA22-7790-02&DT=20020110122508

Register with the TSO-REXX list if you have any questions while you are
learning.


Good Luck,

Rob

Ed. Benoit

unread,
Jan 7, 2004, 3:21:40 PM1/7/04
to
Rob,
Thanks for the books information.
Do you know the listserv address of the TSO-REXX list?

Ed.

Rob Zenuk

unread,
Jan 7, 2004, 3:30:36 PM1/7/04
to
From http://www.cbttape.org/internet.phtml

Topic: REXX programming language under TSO/E and ISPF
Name: TSO-REXX
Type: LISTSERV
Listserv: list...@vm.marist.edu Subscribe to TSO-REXX
List: TSO-...@VM.MARIST.EDU
Web: http://www.marist.edu/htbin/wlvindex?TSO-REXX
News: BIT.LISTSERV.TSO-REXX
Weekday Message Volume: 3 - 15
More information: n/a
Notes: List owner is Duane Weaver at mailto:DD...@OSU.EDU

Rob

Ed. Benoit

unread,
Jan 7, 2004, 4:17:26 PM1/7/04
to
Still need a little more help with the length but only in batch mode.
When I run the clist that call the rexx in foreground it work, but when I run
the clist in batch mode
When I do a set srba = &hexno after the vget (hexno) shared, the clist think
that the length of the variable is too long. I get message: this statement
has a number exceeding the maximum allowable value. I did a set mlen = &length(&
hexno) after the vget (hexno) and it thinks that the length of hexno is
000063bd9027 not the value of hexno.
Below is the clist:
PROC 0
/* RKIDC39 CLIST TO TBCREATE ID.0010 FOR DELETE AND NEWLOG ACTIVE
/*NTROL END(ENDO)
CONTROL END(ENDO) MSG CONLIST LIST FLUSH
ISPEXEC CONTROL ERRORS RETURN
/* SET HEXNO = 000063BD9026
VPUTDB2ID: +
SET HEXNO = 000063BD9026
ISPEXEC VPUT (HEXNO) SHARED
SET RC = &LASTCC
ISPEXEC SELECT CMD(%RKIREX01)
SET RC = &LASTCC
ISPEXEC VGET (HEXNO) SHARED
SET RC = &LASTCC
SET MLEN = &LENGTH(&HEXNO)
SET SRBA = &HEXNO
SET RC = &LASTCC
EXIT

Below is the REXX.
/* REXX */


ADDRESS ISPEXEC
'VGET (HEXNO) SHARED'

NUMERIC DIGITS(15)
SAY HEXNO
HEXNO=D2X(X2D(HEXNO)+1)
SAY HEXNO
HEXNO=RIGHT(HEXNO,12,'0')
SAY HEXNO
'VPUT (HEXNO) SHARED'
EXIT 0

Any suggestions?
Ed.

BUDBILL, GENE

unread,
Jan 7, 2004, 4:53:02 PM1/7/04
to
-----Original Message-----
From: ISPF discussion list [mailto:ISP...@LISTSERV.ND.EDU] On Behalf Of
Ed. Benoit
Sent: Wednesday, January 07, 2004 1:07 PM
To: ISP...@LISTSERV.ND.EDU
Subject: Re: Adding one to a HEX number

BUDBILL, GENE

unread,
Jan 7, 2004, 4:55:43 PM1/7/04
to
I think I hit send before I typed anything in the last message.

Try wrapping your &HEXNO variable in a &STR function.

Gene

From a help file...

Including Leading and Trailing Blanks and Leading Zeros

If you want leading and trailing blanks and leading zeros in a &LENGTH

expression included in the assignment, enclose the expression in a &STR

built-in function. Otherwise, the blanks and zeroes are ignored.

For example, suppose that you want to save the length of the variable

&IFIELD in a variable called &SLNGTH. The contents of &IFIELD are 0

472.20. Include &IFIELD in the &STR built-in function to include the

blanks and the leading zero as part of the assignment:

SET SLNGTH= &LENGTH(&STR(&IFIELD))

After the previous statement executes, &SLNGTH contains the value 8.

Ed. Benoit

unread,
Jan 7, 2004, 5:44:52 PM1/7/04
to
All is well with the problem. Everything is working AOK.
Thanks to all for all the help.
Ed.

Gardiner, Roy

unread,
Jan 8, 2004, 4:04:35 AM1/8/04
to
The genius of Mike Cowlishaw (inventor of Rexx) is that Rexx is easy, easy;
especially if you already know Clist.

The IBM TSO Language Reference for Rexx is fairly readable; huge chunks of
it are taken from Mike's original The Rexx Language.

Then find a simple Clist dialog what you wrote and convert it.
Alternatively, you will probably find a zillion Rexx execs in your SYSPROC
and SYSEXEC concatenations to look at for inspiration. Copy a (harmless!)
one and mess with it. You'll soon break it!

Good luck.

> -----Original Message-----
> From: Ed. Benoit [SMTP:Ibm...@AOL.COM]
> Sent: Wednesday, January 07, 2004 7:11 PM
> To: ISP...@LISTSERV.ND.EDU
> Subject: Re: Adding one to a HEX number
>

> *** WARNING : This message originates from the Internet ***


The Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB

The Royal Bank of Scotland plc is authorised and regulated by the Financial Services Authority and represents The Royal Bank of Scotland Marketing Group. The Bank sells life policies, collective investment schemes and pension products and advises only on the Marketing Group's range of these products and on a With-Profit Bond produced by Norwich Union Life (RBS) Limited.

This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate.

Mark Zelden

unread,
Jan 8, 2004, 9:44:49 AM1/8/04
to
On Thu, 8 Jan 2004 08:36:55 -0000, Gardiner, Roy <roy.ga...@RBS.CO.UK>
wrote:

>Then find a simple Clist dialog what you wrote and convert it.

That is exactly how I started learning REXX in 1991. I left a job
that had MVS/XA 2.2 without REXX and went to a shop that had MVS/XA 2.2
with REXX (it was optional then). I took a couple of simple
edit macros written in CLIST and converted them. I never looked
back.

--
Mark Zelden
Sr. Software and Systems Architect
mailto: mark....@zurichna.com
Systems Programming expert at http://Search390.com/ateExperts/
Mark's MVS Utilities: http://home.flash.net/~mzelden/mvsutil.html

JB Moore

unread,
Jan 8, 2004, 10:10:31 AM1/8/04
to
Ditto for me as well, Mark. Initially, I was slightly "gun shy" with regard
to REXX 'cuz I knew CLIST so well. But as soon as I started dabbling, I knew
I'd never go (well, almost never) back to CLISTs.

Big ticket improvements that hooked me and hooked me good:

"case oblivious" - both in source and data manipulation
native decimal math plus hex manipulation
easy memory addressing, again, native to the language
nearly a one-for-one correlation in BIFs...plus ones that CLISTs didn't have

Just all around an easier language to teach and learn. I guess you could
say, more "industry standard" than the CLIST syntax.

I still occasionally put a CLIST together and I fact prefer them for simple
TSO LOGON scripts where the "source" code looks more like a MS-DOS ".bat"
file. That is, nothing but lists of TSO/E commands.

Try TSOLIB with REXX. Then try it with CLIST.

You'll see what I mean.

Jim Moore

P.S. I was actually exposed to REXX long before it appeared in MVS. I saw it
and looked into it at a VM/VSE site in the late 1980s.


----- Original Message -----
From: "Mark Zelden" <mark....@ZURICHNA.COM>
To: <ISP...@LISTSERV.ND.EDU>
Sent: Thursday, January 08, 2004 8:41 AM
Subject: Re: Adding one to a HEX number

0 new messages