Pascal:不兼容的类型:得到“LONGINT”预期的“CHAR”
我不断收到“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;
I keep getting the "98 / 39 comp1_~1.pas
Error: Incompatible types: got "LONGINT" expected "CHAR". This is concerning line 6. Any help please.
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么问题出在哪里呢?
BowlDieResult
是一个char
,但您要为其分配一个longint
。我的帕斯卡有点生锈了,但是试试
So what's the problem?
BowlDieResult
is achar
but you're assigning alongint
to it.My pascal is a bit rusty, but try