String Scramble

0 pts.
Tags:
RPG ILE
I need to take a 10 character alphanumeric string input by the user and redisplay that string with the letters scrambled and at a loss how to go about it. It has been awhile since I have programmed in RPG. Is there a RANDOM function in RPGIV like in windows programming?
ASKED: January 18, 2006  11:01 AM
UPDATED: January 18, 2006  9:21 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you’re using ILE, there’s an ILE API (CEERAN0 – that’s a zero) that can be called to generate a random value between 0 and 1.

The following example shows how to call it…

* Prototype for Random Number API…

D Random pr ExtProc(‘CEERAN0′)
D Seed 5i 0 Const
D RandomNum 8f
D fc 12a Options(*OMIT)

* Work variables…

D RandomNum s 8f
D Result S 2s 0
D HiVal S 10i 0 Inz(10)
D LoVal S 10i 0 Inz(1)

* Call the API, “RandomNum” holds a value between 0 and 1…

C Callp Random(0 : RandomNum : *OMIT)

* Convert the generated number so it falls within our range…

C Eval Result = %Int(RandomNum * HiVal) + LoVal

C ‘Result’ Dsply Result
C Eval *InLr = *On

Hope it helps

Jonathan

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following