Article

From:
To:
Jimmie Shahan
Subject:
Re: Indy IdHL7 Component
Newsgroup:
borland.public.delphi.internet.winsock

Re: Indy IdHL7 Component

Jimmie Shahan wrote:
> Does anyone have a demo project using the IdHL7 Componet supplied in 
> Indy 9 that they would be willing to share?  Please send any sample code 
> to ✉jshahan.com.

example:

   object hl7server: TIdHL7      Port = 2000      IPRestriction = '0.0.0.0'      IPMask = '0.0.0.0'      CommunicationMode = cmSynchronous      OnConnect = hl7serverConnect      OnDisconnect = hl7serverDisconnect      Left = 232      Top = 24    end    object hl7client: TIdHL7      Address = 'localhost'      Port = 2000      IPRestriction = '0.0.0.0'      IPMask = '0.0.0.0'      CommunicationMode = cmSynchronous      IsListener = False      OnConnect = hl7clientConnect      OnDisconnect = hl7clientDisconnect      Left = 270      Top = 26    end

unit Unit1;
interface
uses    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,    StdCtrls, IdBaseComponent, IdHL7;
type    TForm1 = class(TForm)      hl7server: TIdHL7;      hl7client: TIdHL7;      Button1: TButton;      Button2: TButton;      Label1: TLabel;      Label2: TLabel;      Label3: TLabel;      Label4: TLabel;      Label5: TLabel;      Label6: TLabel;      Memo1: TMemo;      Memo2: TMemo;      Memo3: TMemo;      Memo4: TMemo;      Button3: TButton;      procedure Button1Click(Sender: TObject);      procedure hl7serverConnect(Sender: TObject);      procedure hl7serverDisconnect(Sender: TObject);      procedure Button2Click(Sender: TObject);      procedure hl7clientConnect(Sender: TObject);      procedure hl7clientDisconnect(Sender: TObject);      procedure FormCreate(Sender: TObject);      procedure Button3Click(Sender: TObject);    private      { Private declarations }      FSent : string;      FReply : string;      procedure incoming(ASender: TObject; AMsg: String; var VHandled: Boolean; var VReply: String);
   public      { Public declarations }    end;
var    Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject); begin    if hl7server.Status = isStopped then      begin      hl7server.start;      Button1.caption := 'Stop Server';      end    else      begin      hl7server.stop;      Button1.caption := 'Start Server';      end; end;
procedure TForm1.hl7serverConnect(Sender: TObject); begin    label1.caption := 'Connected'; end;
procedure TForm1.hl7serverDisconnect(Sender: TObject); begin    label1.caption := 'Disconnected'; end;
procedure TForm1.Button2Click(Sender: TObject); begin    if hl7client.Status = isStopped then      begin      hl7client.start;      Button1.caption := 'Stop Client';      end    else      begin      hl7client.stop;      Button1.caption := 'Start Client';      end; end;
procedure TForm1.hl7clientConnect(Sender: TObject); begin    label2.caption := 'Connected'; end;
procedure TForm1.hl7clientDisconnect(Sender: TObject); begin    label2.caption := 'Disconnected'; end;
procedure TForm1.FormCreate(Sender: TObject); begin    hl7server.OnReceiveMessage := incoming; end;
procedure TForm1.incoming(ASender: TObject; AMsg: String; var VHandled: Boolean; var VReply: String); begin    // can't use the memo's directly - in the wrong thread    FSent := AMsg;    VHandled := true;    VReply := FReply; end;
procedure TForm1.Button3Click(Sender: TObject); var    s : string; begin    FReply := Memo2.text;    FSent := '';    case hl7client.SynchronousSend(memo1.text, s) of      srError : raise exception.create('internal error: '+s);      srNoConnection : raise exception.create('not connected');      srTimeout : raise exception.create('no response from server');      srOK : begin        memo3.text := FSent;        memo4.text := s;        end;      srSent : raise exception.create('can''t happen');    end;
end;
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Sat, 23 Nov 2024 16:46:02 UTC
Copyright © 2009-2024
HREF Tools Corp.