unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  SNMPsend, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label6: TLabel;
    Memo1: TMemo;
    Memo2: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form1: TForm1; 

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  response, s: string;
  n: integer;
begin
  if Length(Edit2.Text) = 0 then Edit2.Text := 'public';
  //
  if SNMPget(Edit3.Text, Edit2.Text, Edit1.Text, response) then begin
    label6.Caption := 'Sucesso...';
    s := '';
    if Length(response) > 0 then begin
      memo1.Clear;
      memo1.Lines.add(response);
      for n := 0 to Length(response) do
        s := s + '$' + IntToHex(Ord(response[n]), 2) + ' '
    end else
      memo1.Lines.add('resposta vazia');
    //
    if Length(s) = 0 then
      memo2.Lines.add('sem dados')
    else begin
      memo2.clear;
      memo2.Lines.add(s);
    end;
  end else begin
    label6.Caption:='Não conectado... (Verifique o host SNMP, comunidade ou MIB OID!)';
    memo1.Lines.Clear;
    memo2.Lines.Clear;
  end;
end;

initialization
  {$I Unit1.lrs}

end.

