PosEx 这个涵数在那个单元里呢,我怎么在帮助里找不到这个函数!
解决方案 »
- 高人指点——如何调用驱动程序(.ll)--在线等啊。
- 关于搜索文件程序的问题
- 【求救】在代码中给第三方控件属性赋值的问题?
- delphi中如何远程调用一个用C 或 shell 编写的程序?
- 谁有epson控制码的相关资料?。
- 求解算法
- 急聘,急聘,急聘,Delphi兼职一名。
- 帮帮我,我在实现一个tray功能,为什么那个图标老是显示不出来,那个位置处只是一片空白?程序如下?
- 如何在代码中实现备份pordaxs的数据库?
- 请问有没有可以指定透明色的画图函数?TransparentBlt我在98下调用不了,真是奇怪
- HLP??如何判断Variant类型是不是为空???
- 将一串数字通Pchar() 发出去后..
StrUtils
category
string handling routines
declaration
function PosEx(Str, Source : string, StartFrom : cardinal = 1): integer;
description
Returns an integer specifying the position of the first occurrence of one string within another, where the search starts at a specified position. PosEx looks for the first complete occurence of Str in Source, beginning the search at StartFrom. If it finds one, it returns the character position in Source of the first character in Str as an integer value, otherwise it returns 0. PosEx also returns 0 if StartFrom is greater then Length(Source) or if StartPos is < 0
example
var s : string;
i : integer;
s:='DELPHI PROGRAMMING';
i:=PosEx('HI PR', s, 4);
//i=1;
in real code
String Types in Delphi
Understanding and managing string data types in Delphi's Object Pascal. Learn about differences between Short, Long, Wide and null-terminated strings.
StrUtils
Classes,SysUtils;已经包含了,但还是出现以下错误
[Error] unitFun.pas(42): Undeclared identifier: 'PosEx'
function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
var
I,X: Integer;
Len, LenSubStr: Integer;
begin
if Offset = 1 then
Result := Pos(SubStr, S)
else
begin
I := Offset;
LenSubStr := Length(SubStr);
Len := Length(S) - LenSubStr + 1;
while I <= Len do
begin
if S[I] = SubStr[1] then
begin
X := 1;
while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do
Inc(X);
if (X = LenSubStr) then
begin
Result := I;
exit;
end;
end;
Inc(I);
end;
Result := 0;
end;
end;
function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
begin
Result := pos(SubStr, copy(s, Cardinal, Length(s) - Cardinal + 1)) + Cardinal - 1;
end;
///////////////////
还有一个无关紧要的问题就是你上面写错了,不是SysUtils,而是StrUtils
function PosEx1(const SubStr, S: string; Offset: Cardinal = 1): Integer;
begin
Result := pos(SubStr, copy(s, Offset, Length(s) - Offset + 1)) + Offset - 1;
end;