AT — различия между версиями
Материал из Фабиус wiki
Hisava (обсуждение | вклад) м |
Hisava (обсуждение | вклад) м |
||
| Строка 10: | Строка 10: | ||
b1 := at( pref_from, xml_text ) | b1 := at( pref_from, xml_text ) | ||
| + | |||
| + | = Полный текст функции = | ||
| + | |||
| + | { TQREvAtFunction } | ||
| + | |||
| + | type | ||
| + | TQREvAtFunction = class(TQREvElementFunction) | ||
| + | public | ||
| + | function Calculate: TQREvResult; override; | ||
| + | end; | ||
| + | |||
| + | function TQREvAtFunction.Calculate: TQREvResult; | ||
| + | var | ||
| + | OffSet: integer; | ||
| + | begin | ||
| + | if (ArgList.Count >= 2) and | ||
| + | (Argument(0).Kind = ResString) and | ||
| + | (Argument(1).Kind = ResString) then | ||
| + | begin | ||
| + | Result.Kind := ResInt; | ||
| + | if (ArgList.Count > 2) then | ||
| + | OffSet := QrEvResultToInt(Argument(2)) | ||
| + | else | ||
| + | OffSet := 1; | ||
| + | Result.IntResult := PosEx(Argument(0).StrResult, Argument(1).StrResult, OffSet); | ||
| + | end | ||
| + | else | ||
| + | Result := ErrorCreate(Format(SqrExpWrongArguments, ['AT'])); | ||
| + | end; | ||
Версия 16:34, 10 июня 2016
at - это функция, написанная на Delphi в файле Qr_expr.pas
AT( <Exp>, <Exp> )
Позиция первого вхождения подстроки в символьную строку
At( 'что искать', 'где искать' )
Примеры
b1 := at( pref_from, xml_text )
Полный текст функции
{ TQREvAtFunction }
type
TQREvAtFunction = class(TQREvElementFunction) public function Calculate: TQREvResult; override; end;
function TQREvAtFunction.Calculate: TQREvResult; var
OffSet: integer;
begin
if (ArgList.Count >= 2) and
(Argument(0).Kind = ResString) and
(Argument(1).Kind = ResString) then
begin
Result.Kind := ResInt;
if (ArgList.Count > 2) then
OffSet := QrEvResultToInt(Argument(2))
else
OffSet := 1;
Result.IntResult := PosEx(Argument(0).StrResult, Argument(1).StrResult, OffSet);
end
else
Result := ErrorCreate(Format(SqrExpWrongArguments, ['AT']));
end;