× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Thanks Vern...VB has multiple meanings for the ampersand - thanks for
picking the right one for me.

Does the rest of the code look reasonable?

And I did catch the commas...well, the compiler helped. :)

On Wed, Jul 28, 2010 at 10:05 AM, Vern Hamberg <vhamberg@xxxxxxxxxxx> wrote:

Michael

The ampersand in VB is concatenation, not bitwise and - NumericToCode is
being built up a character at a time. So change

NumericToCode = %BitAnd(%SubStr(digits, digitValue + 1,
1):NumericToCode);

to

NumericToCode = %SubStr(digits : digitValue + 1 : 1) + NumericToCode;


The delimiters for RPG are not commas, so I changed that, too. I know
you'da caught that!!

Vern

On 7/28/2010 8:49 AM, Michael Ryan wrote:
It's to make a double secret number (character string) for a vendor.
They're
doing a survey, and they want to have this number for identification.
I've
got some VB code, but I'm not sure how to convert it to RPG. Here's the
VB
code:

' 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,
1):NumericToCode);
EndDo;

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 AM

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



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

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.