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



Cool, thanks Chris!

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Chris Pando
Sent: Wednesday, June 18, 2008 12:26 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: Random Character string generator???

On Wed, Jun 18, 2008 at 10:47 AM, Jon Allen <jallen@xxxxxxxxx> wrote:
I need to generate a random string of characters....

Best way to do this in RPGLE?

Thanks!


Best is a matter of opinion. Here is a 10 character
random password generator:

d randPwd pr 10a
d random pr ExtProc('CEERAN0')
d 10u 0
d 8f
d 12 Options(*Omit)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* ... generate random password ... *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
p randPwd b
d pi 10a
d seed s 10u 0 Inz(0)
d floater s 8f
d fc s 12a
d pwd s 10a
d $I s 3s 0
d alpha s 26a Inz('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
/free
For $I = 1 to 10;
random( seed: floater : fc );
%SubSt( pwd : $I : 1 ) =
%SubSt( alpha : %Int(floater * 26 + 1) : 1 );
EndFor;
Return pwd;
/end-free
p randPwd e

A call looks like:

rndPwd = randPwd();


HTH,

Chris
--
chris@xxxxxxxxx
www.brilligware.com

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.