A
A
Alertoso2021-05-23 12:35:52
Delphi
Alertoso, 2021-05-23 12:35:52

How to fix error E2066?

There is a procedure for filling arrays:

Procedure FillArrays (var ArrI, ArrFB: TArr; const Row: Integer; const ArrType: TSet);
Var
  i: Integer;
Begin
  if ArrType = Sorted then
    for i := 1 to Row do
      ArrI[i] := i
  else if ArrType = Reversed then
    for i := 1 to Row do
      ArrI[i] := Row - i + 1
  else
    for i := 1 to Row do
      ArrI[i] := Random(Row);

  ArrFB := ArrI;
End;

The announcements are as follows:
Type
  TArr = array [1..3000] of Integer;
  TARows = array [1..6] of Integer;
  TSet = (Sorted, Reversed, Random);
  TResArr = array [1..6, 1..12] of Integer;

Const
  ARows: TARows = (100, 250, 500, 1000, 2000, 3000);
  Output: array [1..3] of String = ('   Sorted   ', '   Reversed   ', '   Random   ');

Var
  InsertSortArr, FBubbleSortArr: TArr;
  ResArr: TResArr;
  i, j, IndRes: Integer;
  SortKind: TSet;

I don't understand why the error occurs: E2066 Missing operator or semicolon, please help me understand what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OCTAGRAM, 2021-05-23
@Alertoso

TSet = (Sorted, Reversed, Random);
This declaration made Random a constant with higher visibility precedence than System.Random.
Solutions:
In new Delphi you can write (at the beginning of the code)
{$SCOPEDENUMS ON}
and replace

if ArrType = TSet.Sorted then
// …
else if ArrType = TSet.Reversed then

Then TSet.Random cannot intersect with System.Random
You can, on the contrary, use a fully qualified identifier when using System.Random:
ArrI[i] := System.Random(Row);
Or you can simply rename TSet.Random to something that is not exactly Random

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question