Solved

input random elements to an array

Posted on 1998-08-06
3
224 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Extract small icon from a TMemoryStream or TIcon 3 723
Rave Reports - Adding a Data Band 1 1,021
Delphi Thead Pool or (only run last procedure called) 13 808
JSon parser in Delphi 1 7,207
While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

763 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