Forget that I did that. I see my error.

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@bama.ua.edu] On
Behalf Of Ward, Mike S
Sent: Tuesday, August 02, 2011 1:37 PM
To: IBM-MAIN@bama.ua.edu
Subject: Re: "base" arithmetic in REXX

I'm not sure what you're trying to do, but how about this?


/* REXX */
XSTRING = abcde119900116688fABCDEF
XTABLEO = 1234567891234567892345678912345678912345678923456789
XTABLEI = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
X = TRANSLATE(XSTRING,XTABLEI,XTABLEO)
 say X
RETURN



-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-MAIN@bama.ua.edu] On
Behalf Of John McKown
Sent: Monday, August 01, 2011 4:22 AM
To: IBM-MAIN@bama.ua.edu
Subject: "base" arithmetic in REXX

anybody know an easy way to encode a base 10 number into base 26?
Basically, I want to make a decimal number into the English alphabet:
A-Z. I was hoping there was a simpler way than:

i=input_number
output=""
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
do while i>0
   j=i//26
   output=substr(alphabet,j+1,1)||output
   i=i%26
end
output="A"||output
output=strip(output,"L","A") /* strip leading "A"s */
if 0 = length(output) then output="A"

-- 
John McKown
Maranatha! <><

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

==========================
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity
to which they are addressed. If you have received this email in error
please notify the system manager. This message
contains confidential information and is intended only for the
individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please notify
the sender immediately by e-mail if you
have received this e-mail by mistake and delete this e-mail from your
system. If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any
action in reliance on the contents of this
information is strictly prohibited.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

==========================
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity
to which they are addressed. If you have received this email in error please 
notify the system manager. This message
contains confidential information and is intended only for the individual 
named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please notify the 
sender immediately by e-mail if you
have received this e-mail by mistake and delete this e-mail from your system. 
If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any action in 
reliance on the contents of this
information is strictly prohibited.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to