Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

input random elements to an array

Posted on 1998-08-06
3
Medium Priority
?
247 Views
Last Modified: 2010-04-16
If I have an array or an type of all "char" ,  how can I  input a random result from that array into a smallar array, f.x.  array [1..5] of Char;
, or better, a few arrays of that same type.
0
Comment
Question by:gudbgud
  • 2
3 Comments
 

Author Comment

by:gudbgud
ID: 1217273
Edited text of question
0
 

Author Comment

by:gudbgud
ID: 1217274
Edited text of question
0
 
LVL 2

Accepted Solution

by:
vx earned 100 total points
ID: 1217275
I coded a little program for you; I think it does what you mean:

Var FirstArray: Array[1..100] of Char;          { The whole array }
    SecArray:   Array[1..5] of Char;            { The new array }
    Counter:    Integer;                        { A random number }

Begin
  Repeat
    Randomize;                                  { Initialize random sequence }
    Counter := Random(100)+1;                   { Create a random number and add one to that }
                                                { Random generates a number from 0<=x<100 }
                                                { The array shouldn't be addresses with 0, so add one }
    SecArray := FirstArray[Counter];            { Copy a number from the first array to the second }
  Until KeyPressed;
End.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question