QrAddFn2 — различия между версиями
Материал из Фабиус wiki
Hisava (обсуждение | вклад) м (→{ TQREvIdHTTPGet }) |
Hisava (обсуждение | вклад) м (→{ TQREvIdHTTPGet }) |
||
| Строка 7: | Строка 7: | ||
'''type''' | '''type''' | ||
TQREvIdHTTPGet = '''class''' ( TQREvElementFunction ) | TQREvIdHTTPGet = '''class''' ( TQREvElementFunction ) | ||
| − | public | + | '''public''' |
| − | function Calculate: TQREvResult; override; | + | '''function''' Calculate: TQREvResult; '''override'''; |
| − | end; | + | '''end'''; |
| − | function TQREvIdHTTPGet.Calculate: TQREvResult; | + | '''function''' TQREvIdHTTPGet.Calculate: TQREvResult; |
| − | var | + | '''var''' |
IdHTTP1: TIdHTTP; | IdHTTP1: TIdHTTP; | ||
| − | res: string; | + | res: '''string'''; |
| − | begin | + | '''begin''' |
| − | try | + | '''try''' |
IdHTTP1 := TIdHTTP.Create(); | IdHTTP1 := TIdHTTP.Create(); | ||
res := IdHTTP1.Get( 'http://' + Argument( 0 ).strResult ); | res := IdHTTP1.Get( 'http://' + Argument( 0 ).strResult ); | ||
Result.StrResult := res; | Result.StrResult := res; | ||
Result.Kind := ResString; | Result.Kind := ResString; | ||
| − | finally | + | '''finally''' |
FreeAndNil( IdHTTP1 ); | FreeAndNil( IdHTTP1 ); | ||
| − | end | + | '''end''' |
| − | end; | + | '''end'''; |
'''initialization''' | '''initialization''' | ||
Версия 09:15, 23 марта 2016
QrAddFn2 - это файл программы на языке Pascal ( QrAddFn2.pas )
{ TQREvIdHTTPGet }
implementation
type
TQREvIdHTTPGet = class ( TQREvElementFunction )
public
function Calculate: TQREvResult; override;
end;
function TQREvIdHTTPGet.Calculate: TQREvResult;
var
IdHTTP1: TIdHTTP;
res: string;
begin
try
IdHTTP1 := TIdHTTP.Create();
res := IdHTTP1.Get( 'http://' + Argument( 0 ).strResult );
Result.StrResult := res;
Result.Kind := ResString;
finally
FreeAndNil( IdHTTP1 );
end
end;
initialization
RegisterQRFunction( TQREvIdHTTPGet, 'IdHTTPGet', 'IdHTTPGet( запрос http типа GET )|' + 'Посылает http запрос типа GET', 'Alexey', '1S' );