免费的 Pascal 编译器 - 致命:语法错误,预期 "OF" 但“[”找到......?
Free Pascal Compiler - Fatal: Syntax error, "OF" expected but "[" found ...?
我定义了这个过程,其中
<code>Player
是用户定义的 record.Here 是过程:
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;
但是我得到这个错误:
main.pas(9,39) Fatal: Syntax error, "OF" expected but "[" found
我已经检查过
行
procedure print_scores(players : array[1..2] of Player);
是第 9 行。
您不能在过程参数列表中定义数组类型。必须单独定义。
type
TPlayers = array[1..2] of TPlayer;
程序是:
procedure print_scores(const Players: TPlayers);
我定义了这个过程,其中
<code>Player
是用户定义的 record.Here 是过程:
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;
但是我得到这个错误:
main.pas(9,39) Fatal: Syntax error, "OF" expected but "[" found
我已经检查过
行procedure print_scores(players : array[1..2] of Player);
是第 9 行。
您不能在过程参数列表中定义数组类型。必须单独定义。
type
TPlayers = array[1..2] of TPlayer;
程序是:
procedure print_scores(const Players: TPlayers);