免费Pascal编译器 - 致命:语法错误,“OF”预期但“[”发现......?

时间:2017-12-25 18:16:11

标签: pascal freepascal

我已经定义了这个过程,其中

Player 
是用户定义的记录。这是程序:

Player

但是我收到了这个错误:

  

main.pas(9,39)致命:语法错误,“OF”预期但“[”找到

我检查了一行

procedure print_scores(players : array[1..2] of Player);
begin
    writeln;
    writeln(' Player 1 (', players[1].player_name.firstname, ' ',players[1].player_name.lastname, ') |=| ', players[1].score);
    writeln(' Player 2 (', players[2].player_name.firstname, ' ',players[2].player_name.lastname, ') |=| ', players[2].score);
    writeln;
end;

是第9行。

1 个答案:

答案 0 :(得分:2)

您无法在过程参数列表中定义数组类型。它必须单独定义。

type
  TPlayers = array[1..2] of TPlayer;

程序是:

procedure print_scores(const Players: TPlayers);