delphi语句出错

来源:百度知道 编辑:UC知道 时间:2024/06/23 23:02:09
从网上找了段代码,为什么这么多错误啊,请大家帮忙看一下.小弟刚学
function IsIncludeChinese(string s):boolean;
//此处出错,Identifier expected but 'STRING' found
var
i:integer;
begin
for i:= 1 to length(s) do//出错,Incompatible types
begin
if (s[i]>128) then
//出错,Comparing signed and unsigned types - widened both operands
begin
result := true;
break;
end
end
result := false;//Missing operator or semicolon
end;

function IsIncludeChinese(s :string):boolean;
var
i :integer;
begin
for i := 1 to length(s) do
begin
if (ord(s[i]) > 128) then
begin
result := true;
Exit;
end
end;
result := false;
end;

调用:
if IsIncludeChinese('中国万岁') then
showmessage('字符串中含有中文字符')
else
showmessage('字符串中不含中文字符');