Паскаль: Несовместимые типы: получил "LONGINT", ожидается "CHAR" - PullRequest
1 голос
/ 21 мая 2011

Я продолжаю получать "98/39 comp1_ ~ 1.pas Ошибка: несовместимые типы: получил "LONGINT", ожидается "CHAR". Это касается строки 6. Любая помощь, пожалуйста.

Function RollBowlDie(VirtualDiceGame : Boolean) : Integer;
  Var
    BowlDieResult : Char;
  Begin
      If VirtualDiceGame
      Then BowlDieResult := Random(6) + 1
      Else
        Begin
        Repeat
          Writeln('Please roll the bowling die and then enter your result.');
          Writeln;
          Writeln('Enter 1 if the result is a 1');
          Writeln('Enter 2 if the result is a 2');
          Writeln('Enter 3 if the result is a 4');
          Writeln('Enter 4 if the result is a 6');
          Writeln('Enter 5 if the result is a 0');
          Writeln('Enter 6 if the result is OUT');
          Writeln;
          Write('Result: ');
          Readln(BowlDieResult);
          If not (BowlDieResult in ['1'..'6'])
          Then
              Begin
              Writeln;
              Writeln('That was not one of the allowed options. Please try agai:');
              End;
          Until BowlDieResult in ['1'..'6'];
        End;
RollBowlDie := Ord(BowlDieResult)  - Ord('0');
  End;

1 Ответ

2 голосов
/ 21 мая 2011

Так в чем же проблема?

BowlDieResult - это char, но вы присваиваете ему longint.

Мой паскаль немного ржавый, но попробуйте

 BowlDieResult := chr(49 + Random(6));
...