Skip to content

Variables looping and grouping

In while-do and repeat-until loops we wrote a condition checking structure: the if-then-else construct.

What does it mean?

Simply this a fundamental control system to make the compiler take decisions, basing them on predeterminable situations.

In last code we needed to make loops stoppable, in particular making the i-condition false (assigning 0 because i is declared intefer).

So we actually have that (in prseudocode):
if (i >0 that is condition = true) then
i becomes 0
else
i will increase by 1;

You can understand the so great importance of this kind of construct, which permits the so called conditional programming.

Well... we have almost terminated present article.

You must how to set a new length for an array.

SetLength(UnlimitedPlayers, Length(UnlimitedPlayers)+1 );

SetLength procedure accepts two parameters: first is the subject to modify by length, the second is the chosen length.
Here we set new array's length equal to previous one + 1.
UnlimitedPlayers is dynamic, so its actual length is determined by the number of items put inside it.
If UnlimitedPlayers was multidimensional we'd have to write SetLength(MyArray, length1D, length2D,...); .

Now the Memo.
Memo is a visual log where to print some info, in form of strings or chars.
It's not a simple variable, nor a composed one like an array; it's more complex.
For now you must know that it can "hosts" functions/procedure, more commonly called methods.

We want to make strings appear in Memo, so we'll use a method to do it. Here it is:

Memo.Lines.Add('Your local integer is : ' + inttostr(LocalInteger));

Method is Add, which adds its argument to the actual empty line of Memo.
Notice the function inttostr(integer-number); returns the chars matching with every digit of integer-number.
Association is based on ASCII table.

Finally the randomic procedure and function:

Randomize;
i:=Random(100);

Randomize procedure sets the so called seed to a new value, which to start the pseudo random numbers from.
Random function generates a number starting from the seed, and the arguments forces it to be between 0 included and 100 excluded.

With these explanations you can understand the following code.