帕斯卡非法表达

ora*_*nge 0 pascal loops if-statement

它停止在第54和58行编译时出现错误'错误:非法表达'和'语法错误,; 期待,但ELSE分别找到了.我的线条位置错了吗?

Procedure PlayDiceGame(PlayerOneName, PlayerTwoName : String;
                           VirtualDiceGame : Boolean; Var TopScores : TTopScores);
      Var
        PlayerOut : Boolean;
        CurrentPlayerScore : Integer;
        AppealDieResult : Integer;
        PlayerNo : Integer;
        PlayerOneScore : Integer;
        PlayerTwoScore : Integer;
        BowlDieResult : Integer;
        RunsScored : Integer;
        NumberOfBalls : Integer;
      Begin
        For PlayerNo := 1 To 2
          Do
            Begin
            NumberOfBalls := 0;
              CurrentPlayerScore := 0;
              PlayerOut := False;
              If PlayerNo = 1
                Then Writeln(PlayerOneName, ' is batting')
                Else Writeln(PlayerTwoName, ' is batting');
              Writeln;
              Writeln('Press the Enter key to continue');
              Readln;
              Repeat
                BowlDieResult := RollBowlDie(VirtualDiceGame);
                If BowlDieResult In [1..4]
                  Then
                    Begin
                      RunsScored := CalculateRunsScored(BowlDieResult);
                      DisplayRunsScored(RunsScored);
                      CurrentPlayerScore := CurrentPlayerScore + RunsScored;
                      Writeln('Your new score is: ', CurrentPlayerScore);
                    End;
                If BowlDieResult = 5
                  Then Writeln('No runs scored this time.  Your score is still: ',
                              CurrentPlayerScore);
                If BowlDieResult = 6
                  Then
                    Begin
                      Writeln('This could be out... press the Enter key to find out.');
                      Readln;
                      AppealDieResult := RollAppealDie(VirtualDiceGame);
                      DisplayAppealDieResult(AppealDieResult);
                      If AppealDieResult >= 2
                        Then PlayerOut := True
                        Else PlayerOut := False;
                    End;
                Writeln;
                Writeln('Press the Enter key to continue');
                Readln;
                NumberOfBalls = NumberOfBalls + 1
              Until PlayerOut or (NumberOfBalls = 6);
              If (NumberOfBalls = 6) Then
              Writeln('You have faced 6 balls and compeletd your innings');
              Writeln('Your final scoare was: ', CurrentPlayerScore);
              Else
              Writeln('You are out.  Your final score was: ', CurrentPlayerScore);
              Writeln;
              Writeln('Press the Enter key to continue');
              Readln;
              If PlayerNo = 1
                Then PlayerOneScore := CurrentPlayerScore
                Else PlayerTwoScore := CurrentPlayerScore;
            End;
        DisplayResult(PlayerOneName, PlayerOneScore, PlayerTwoName, PlayerTwoScore);
        If (PlayerOneScore >= PlayerTwoScore)
          Then
            Begin
              UpdateTopScores(TopScores, PlayerOneName, PlayerOneScore);
              UpdateTopScores(TopScores, PlayerTwoName, PlayerTwoScore);
            End
          Else
            Begin
              UpdateTopScores(TopScores, PlayerTwoName, PlayerTwoScore);
              UpdateTopScores(TopScores, PlayerOneName, PlayerOneScore);
            End;
        Writeln;
        Writeln('Press the Enter key to continue');
        Readln;
      End;
Run Code Online (Sandbox Code Playgroud)

How*_*ard 5

你有一个多行then

If (NumberOfBalls = 6) Then
    Writeln('You have faced 6 balls and compeletd your innings');
    Writeln('Your final scoare was: ', CurrentPlayerScore);
Else
Run Code Online (Sandbox Code Playgroud)

将它包装在开头/结尾,它应该可以工作.