: : : This message was edited by Rico124a at 2004-9-4 18:43:44
: : : How would you go about creating an array that would not repeat results?
: : : example:
: : : I want 15 different results from
: : : aTrait: array [1..100] of string =
: : :
: : : thanks
: : :
: : :
: : What do you mean by 15 different results? If you want 15 different arrays with 100 string elements, you can either create 15 different array variables, or a 2-D array with in the second dimension 15 elements.
: Your giving me way too much credit. Just a simple 1-D array of 100 string elements all pertaining to colors (from white to black). I input that I want 15 colors from that array. What I want to see is 15 different colors spit out into a memobox.
: example: white, red, blue, black, green, yellow, pink, etc .
: not: red, red, blue, green, pink, red, puse, etc.
The trick here is to fill a 15-element array in such a way they you check each element to be added with all previous elements. Here is a simple example:
ColorsArray: array[1..15] of string;
// Example Initializion: Run only once
NumColor := 0;
ColorToBeAdded := 'red';
// Start of "real example code"
FoundColor := False; // Assume the color isn't in the list
if NumColor > 0 then // Check if there are already some added
for i := 1 to NumColor do
if ColorToBeAdded = ColorsArray[i] then
FoundColor := true; // Found a matching color
if not FoundColor then // Add the new color
ColorsArray[NumColor] := ColorToBeAdded;
This code will add the color red to the array. If you run the "real example code" twice with red as color, you will find only 1 element is filled, and NumColor is still 1. Only if you add a non-red color, it will be added.