如题......
解决方案 »
- delphi。。当鼠标移动时,如何获得屏幕当前的鼠标的坐标。。。
- 有关表格读取路径的问题?请帮忙!!
- 我是新手,麻烦告诉我怎么添加一个自定义函数啊
- 哪里有ExpressQuantumGrid 4(控件)下载
- 打印报表预览时‘打印设置’和’打印‘按钮怎么都失效了?
- 一个关于窗体的小问题(不过好象也不应该算是窗体的问题)
- 数据库中原来的‘时间字段的数据怎样清空’,该如何处理100分
- 大把大把的可用分,散点吧!
- 急! ADO Master/detail表的更新问题
- 请问如何获得显示方式是800X600还是600X480?
- DLL的问题,IMAGE为何不能在DLL中?
- 如何用ShellExecute()打开一个新的网页,不覆盖已打开的。
var
buf, resultBuf, estr: wideString;
str1, str2, cstr: string;
cnum, enum, i, j, mnum: integer;
label resultlab, numlab;
begin
//转成宽字符后可以不用判断汉字
buf := str;
resultBuf :=''; //初始化结果
while Length(buf) > width do
begin
estr := copy(buf, 1, width);
Delete(buf, 1, width);
///////////////////////////如有数字,则从后面截取字////////////////////////////////////
mnum := 0;
cstr := estr;
cnum := length(cstr) - length(estr);
enum := 2 * length(estr) - length(cstr);
{ if trunc(cnum + enum / 2) <= width then
begin
if enum mod 2 = 1 then
begin
/////////////////////空格不能插入数字中///////////////////////////////////
str1 := '';
str1 := Copy(estr, Length(estr) - mnum, 1);
while (((str1 >= '0') and (str1 <= '9')) or (str1 = '.')) do
begin
mnum := mnum + 1;
str1 := Copy(estr, Length(estr) - mnum, 1);
end;
enum := enum + 1;
insert(' ', estr, length(estr) - mnum)
//estr := estr + ' ';
end; }
if trunc(cnum + enum / 2) < width then
begin
numlab: if trunc(enum / 2) < length(buf) then
begin
estr := estr + copy(buf, 1, (width - trunc(cnum + enum / 2)));
Delete(buf, 1, (width - trunc(cnum + enum / 2)));
end
else
begin
estr := estr + copy(buf, 1, length(buf));
Delete(buf, 1, length(buf));
goto resultlab;
end; end;
//end;
/////////////////////处理数字///////////////////////
str1 := '';
str2 := '';
mnum := 0;
str1 := Copy(estr, Length(estr), 1);
str2 := copy(buf, 1, 1);
cstr := estr;
cnum := length(cstr) - length(estr);
enum := 2 * length(estr) - length(cstr);
while (((str1 >= '0') and (str1 <= '9')) or (str1 = '.'))
and (((str2 >= '0') and (str2 <= '9')) or (str2 = '.')) do
begin
mnum := mnum + 1;
estr := estr + str2;
delete(buf, 1, 1);
str1 := '';
str2 := '';
str1 := Copy(estr, Length(estr), 1);
str2 := copy(buf, 1, 1);
//showmessage('str1:'+str1+' str2:'+str2);
end;
//showmessage('mnum'+inttostr(mnum)+' width:'+inttostr(width)+' cnum: '+inttostr(cnum)+' enum: '+inttostr(trunc(enum / 2)));
if mnum > (width - cnum - trunc(enum / 2)) + 1 then
begin
str1 := '';
str1 := Copy(estr, Length(estr), 1);
while (((str1 >= '0') and (str1 <= '9')) or (str1 = '.')) do
begin
buf := copy(estr, Length(estr), 1) + buf;
estr := copy(estr, 1, Length(estr) - 1);
str1 := '';
str1 := Copy(estr, Length(estr), 1);
end;
goto resultlab;
end
else
if mnum < (width - cnum - trunc(enum / 2)) + 1 then
if mnum > (width - cnum - trunc(enum / 2)) then
begin
estr := estr + copy(buf, 1, mnum);
//showmessage(estr) ;
delete(buf, 1, mnum);
end;
///////////////////////
cstr := estr;
cnum := length(cstr) - length(estr);
enum := 2 * length(estr) - length(cstr);
if trunc(cnum + enum / 2) < width then
goto numlab;
//////////////////////////
{/////处理标点符号////////////////////////////////////// }
str1 := '';
str1 := copy(buf, 1, 1);
if (str1 = ',') or (str1 = ',') or (str1 = '。') or (str1 = '.') or (str1 = '?') or (str1 = '?')
or (str1 = '!') or (str1 = '!') or (str1 = ';') or (str1 = ';') or (str1 = '、') or (str1 = '》')
or (str1 = '”') or (str1 = '"') or (str1 = ')') or (str1 = ')') then
begin
estr := Copy(estr, 1, Length(estr)) + str1;
delete(buf, 1, 1);
end;
{ /////////////////////加空格////////////////////////////////////////// }
{resultlab: cstr := estr;
cnum := length(cstr) - length(estr); //汉字个数
enum := 2 * length(estr) - length(cstr); //数字个数
if trunc(cnum + enum / 2) < width then
begin
j := 6;
for i := 1 to (width - trunc(cnum + enum / 2)) do
begin
//////////////////空格不能插入数字中////////////////////////
str1 := '';
str1 := copy(estr, j - 1, 1);
while (j = 1) or ((str1 >= '0') and (str1 <= '9')) or (str2 = '.') do //判断是否数字
begin
j := j + 2;
str1 := '';
str1 := copy(estr, j - 1, 1);
end;
insert(' ', estr, j);
j := j + 2;
end;
end;}
resultlab:
if buf = '' then
resultBuf := resultBuf + estr
else
resultBuf := resultBuf + estr + #13#10;
end;
resultBuf := resultBuf + buf;
Result := resultBuf;
end;{=============================================================================}