|
Michael,
A long time ago someone published a Base 10 --> Base 36 converter here:
http://www.mcpressonline.com/programming/general/base-36-algorithm.html
<http://www.mcpressonline.com/programming/general/base-36-algorithm.html>
HTH,
Luis Rodriguez
IBM Certified Systems Expert — eServer i5 iSeries
--
On Wed, Jul 28, 2010 at 9:19 AM, Michael Ryan <michaelrtr@xxxxxxxxx>
wrote:
It's to make a double secret number (character string) for a vendor.I've
They're
doing a survey, and they want to have this number for identification.
got some VB code, but I'm not sure how to convert it to RPG. Here's theVB
code:1):NumericToCode);
' convert a number to any base
' BASE can be in the range 2-31
' NOTE: we have removed the following characters: 0,1,I,L,O
Public Function NumericToCode(ByVal number)
Dim Index
Dim digits
Dim digitValue
Dim base
base = 31
' check base
If base < 2 Or base > 31 Then Err.Raise 5
' get the list of valid digits
digits = Left("23456789ABCDEFGHJKMNPQRSTUVWXYZ", base)
' convert to the other base
Do While number
digitValue = number Mod base
number = number \ base
NumericToCode = Mid(digits, digitValue + 1, 1) & NumericToCode
Loop
End Function
And I think the RPG could be (using the same variables) like this:
DoW Number <> 0;
digitValue = %Rem(number:base);
number = %Int(number / base);
NumericToCode = %BitAnd(%SubStr(digits, digitValue + 1,
EndDo;list
Does this make sense to anyone?
On Wed, Jul 28, 2010 at 9:30 AM, Kirk Yates <kirk.yates@xxxxxxx> wrote:
Reply: Wednesday, July 28, 2010, 8:12:06 AMlist
Sorry, no. What do you base 31 for?
Anyone have a Base 31 converter?
--
Kirk Yates
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx--
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.