本文介绍了Pascal:不兼容的类型:获得“LONGINT”预期的“CHAR”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到的98/39 comp1_〜1.pas
错误:不兼容的类型:获得LONGINT期望CHAR。这是关于第6行。任何帮助。
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;
推荐答案
那么问题是什么?
BowlDieResult
是 char
,但您分配 longint
到它。
我的pascal有点生锈,但尝试
My pascal is a bit rusty, but try
BowlDieResult := chr(49 + Random(6));
这篇关于Pascal:不兼容的类型:获得“LONGINT”预期的“CHAR”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!