例子 edit3.text := leftstr(edit1.text, spinedit1.value);
━━━━━━━━━━━━━━━━━━━━━
首部 function rightstr(const atext: string; const acount: integer): string;
$[strutils.pas
功能 返回字符串atext右边的acount个字符
说明 rightstr('123456', 3) = '456'
参考 function system.copy
例子 edit3.text := rightstr(edit1.text, spinedit1.value);
━━━━━━━━━━━━━━━━━━━━━
首部 function midstr(const atext: string; const astart, acount: integer):
string; $[strutils.pas
功能 返回字符串atext从astart开始的acount个字符
说明 其实就是copy
参考 function system.copy
例子 edit3.text := midstr(edit1.text, spinedit1.value, spinedit2.value);
━━━━━━━━━━━━━━━━━━━━━
首部 function searchbuf(buf: pchar; buflen: integer; selstart, sellength:
integer; searchstring: string; options: tstringsearchoptions = [sodown]):
pchar; $[strutils.pas
功能 返回第一个搜索到的指针位置
说明 这函数常用于文本中搜索字符串
参考 <null>
例子
///////begin searchbuf
function searchedit(editcontrol: tcustomedit; const searchstring: string;
searchoptions: tstringsearchoptions; findfirst: boolean = false): boolean;
var
buffer, p: pchar;
size: word;
begin
result := false;
if (length(searchstring) = 0) then exit;
size := editcontrol.gettextlen;
if (size = 0) then exit;
buffer := stralloc(size + 1);
try
editcontrol.gettextbuf(buffer, size + 1);
p := searchbuf(buffer, size, editcontrol.selstart, editcontrol.sellength,
searchstring, searchoptions);
if p <> nil then begin
editcontrol.selstart := p - buffer;
editcontrol.sellength := length(searchstring);
result := true;
end;
finally
strdispose(buffer);
end;
end;