I don't know rexx, but couldn't you just do an OC of X'F0" into the
letter. A C1 would become F1 a C2 would become F2 and so on.

-----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

Reply via email to