帕斯卡:“或”不支持类型“Char”
我是新来的,如果我做错了什么,很抱歉!
我正在 Lazarus 中制作一个简单的 Pascal 程序,在编译时遇到此错误:
HWE(16,18) 错误:类型“Char”和“常量字符串”不支持操作“或”
这是它抱怨的部分关于:
Repeat
begin
Readln(style);
If style <> ('e' or 'mp' or 'sa') then
Writeln ('do what I say!')
end
Until style = (e or mp or sa);
感谢您的帮助!
I'm new here so sorry if I do something wrong!
I'm making a simple Pascal program in Lazarus and I'm getting this error when compiling:
HWE(16,18) Error: Operation "or" not supported for types "Char" and "Constant String"
Here is the part it's complaining about:
Repeat
begin
Readln(style);
If style <> ('e' or 'mp' or 'sa') then
Writeln ('do what I say!')
end
Until style = (e or mp or sa);
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
or
必须与布尔表达式一起使用,例如or
has to be used with Boolean expressions, like必须使用 AND 运算符:
(在这种情况下不要使用 OR 运算符)
Must use AND operator:
(Don't use OR operator in this case)
使用关系运算符和布尔运算符组合两个布尔表达式时,请小心使用括号。
When combining two Boolean expressions using relational and Boolean operators, be careful to use parentheses.
pascal 有一个很好的方法可以使用 Set 来完成此操作,但仅适用于序数类型(例如 CHAR,但不是字符串):
我经常遇到的一个非常常见的用例是检测 TDataSet 是否正在编辑:
There is a nice way in pascal to do this using Sets, but for ordinal types only (like CHAR, but NOT Strings):
A very common use case I very often come across is to detect if a TDataSet is being edited: