70 lines
1.7 KiB
ObjectPascal
70 lines
1.7 KiB
ObjectPascal
unit xpUtilUnit;
|
|
|
|
{$mode ObjFPC}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
Classes, SysUtils;
|
|
function inArrayPos(const value: string; const checkList: array of string; ignoreCase: boolean): integer;
|
|
// проверяет содержится ли строка в массиве
|
|
function inArray(const value: string; const checkList: array of string; ignoreCase: boolean): boolean;
|
|
// находит индекс числа в массиве
|
|
function inArrayPosN(const value: integer; const checkList: array of integer): integer;
|
|
// проверяет содержится ли число в массиве
|
|
function inArrayN(const value: integer; const checkList: array of integer): boolean;
|
|
|
|
implementation
|
|
uses
|
|
lazUTF8;
|
|
function inArrayPos(const value: string; const checkList: array of string;
|
|
ignoreCase: boolean): integer;
|
|
var
|
|
i: integer;
|
|
s1,s2: string;
|
|
begin
|
|
result := -1;
|
|
|
|
if ignoreCase then
|
|
s1 := UTF8UpperString(value)
|
|
else
|
|
s1 := value;
|
|
for I := Low(checkList) to High(checkList) do
|
|
begin
|
|
if ignoreCase then
|
|
s2 := UTF8UpperString(checklist[i])
|
|
else
|
|
s2 := checklist[i];
|
|
if SameStr(s1, s2) then
|
|
exit(I);
|
|
end;
|
|
end;
|
|
|
|
|
|
function inArray(const value: string; const checkList: array of string;
|
|
ignoreCase: boolean): boolean;
|
|
begin
|
|
result := inArrayPos(value, checkList, ignoreCase)>=0;
|
|
end;
|
|
|
|
function inArrayPosN(const value: integer; const checkList: array of integer
|
|
): integer;
|
|
var
|
|
i: integer;
|
|
begin
|
|
result := -1;
|
|
for I := Low(checkList) to High(checkList) do
|
|
if value = checkList[i] then
|
|
exit(I);
|
|
end;
|
|
|
|
|
|
function inArrayN(const value: integer; const checkList: array of integer
|
|
): boolean;
|
|
begin
|
|
result := inArrayPosN(value, checkList)>=0;
|
|
end;
|
|
|
|
end.
|
|
|