我编了一个函数如下:
function test(ws: WideString) :integer;
begin
if ws='' then
result := 0
else
result :=1;
end;
在一个按钮的CLICK事件下调用该函数:如果test的第一个参数ws 不超过256个字符是可以编译通过,当超过256个字符就不能编译通过,分别如下:
1. 可以编译通过
procedure TForm1.Button2Click(Sender: TObject);
begin
if test('<016*add*del*upd*prn><017*add*de') > 0 then
showmessage('successful')
else
showmessage('fail');
end;
2.不可以编译通过
procedure TForm1.Button2Click(Sender: TObject);
begin
if test('<000><001*add*del*upd*prn><002*add*del*upd*prn><003*add*del*upd*prn><004*add*del*upd*prn><005*add*del*upd*prn><006*add*del*upd*prn><007*add*del*upd*prn><008*add*del*upd*prn><009*add*del*upd*prn><010*add*del*upd*prn><011*add*del*upd*prn><012*add*del*upd*prn><013*add*del*upd*prn><014*add*del*upd*prn><015*add*del*upd*prn><016*add*del*upd*prn><017*add*de') > 0 then
showmessage('successful')
else
showmessage('fail');
end;
出现[Error] Unit1.pas(61): String literals may have at most 255 elements的错误
我有找过帮助文件,WideString 类型可以支持2的30次方个字符,为什么还会出现上面的错误呢?
请各位大侠多多指点!
function test(ws: WideString) :integer;
begin
if ws='' then
result := 0
else
result :=1;
end;
在一个按钮的CLICK事件下调用该函数:如果test的第一个参数ws 不超过256个字符是可以编译通过,当超过256个字符就不能编译通过,分别如下:
1. 可以编译通过
procedure TForm1.Button2Click(Sender: TObject);
begin
if test('<016*add*del*upd*prn><017*add*de') > 0 then
showmessage('successful')
else
showmessage('fail');
end;
2.不可以编译通过
procedure TForm1.Button2Click(Sender: TObject);
begin
if test('<000><001*add*del*upd*prn><002*add*del*upd*prn><003*add*del*upd*prn><004*add*del*upd*prn><005*add*del*upd*prn><006*add*del*upd*prn><007*add*del*upd*prn><008*add*del*upd*prn><009*add*del*upd*prn><010*add*del*upd*prn><011*add*del*upd*prn><012*add*del*upd*prn><013*add*del*upd*prn><014*add*del*upd*prn><015*add*del*upd*prn><016*add*del*upd*prn><017*add*de') > 0 then
showmessage('successful')
else
showmessage('fail');
end;
出现[Error] Unit1.pas(61): String literals may have at most 255 elements的错误
我有找过帮助文件,WideString 类型可以支持2的30次方个字符,为什么还会出现上面的错误呢?
请各位大侠多多指点!
procedure TForm1.Button2Click(Sender: TObject);
begin
if test('<000><001*add*del*upd*prn><002*add*del*upd*prn><003*add*del*upd*prn>' +
'<004*add*del*upd*prn><005*add*del*upd*prn><006*add*del*upd*prn><007*add*del*upd*prn>'+
'<008*add*del*upd*prn><009*add*del*upd*prn><010*add*del*upd*prn><011*add*del*upd*prn><012*add*del*upd*prn><013*add*del*upd*prn><014*add*del*upd*prn><015*add*del*upd*prn><016*add*del*upd*prn><017*add*de') > 0 then
showmessage('successful')
else
showmessage('fail');
end;一个字符串中不能超过255个你把它分开写嘛