• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1089
  • Last Modified:

access a comport

how to access a comport in delphi 7 and read a STRING that came from a barcodescanner. i have tried several components but each of them are missing a file to get them to work under delphi 7. the returnvalue has to be a string for easy handling in the rest of the progran
0
eagle00789
Asked:
eagle00789
  • 6
  • 2
  • 2
1 Solution
 
ILECommented:
hex i use the tcomm component just a second u will have that great component on your hand for few seconds

0
 
ILECommented:
I hava a lot of work with comports in delphi
and i strongly recomand you this component well documented
good help,free, with full source a lot of corectly working events reability and stability in work

yep i found

http://www.delphi32.com/vcl/lists/sc_n_62.asp 

there a lot of components for serial port but ignore all and take tcomport


i hear there is a newer wersion of tcomport from Dejan Crnila but if u find inform me oki?

dont forget STRONGLY RECOMANDATION

:)))  sory for my english



0
 
eagle00789Author Commented:
i can't get it to work under delphi 7. i'm missing a file called DsgnIntf.dcu i searched my harddrive for it. but could not find it
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rl912Commented:
Hello,

try to find AsyncPro of turbopower at sourceforge.org
(search for Turbopower)

should be the solution to your problem.
0
 
eagle00789Author Commented:
it works.
just one more question: how do i clear the buffer variable??

------

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OoMisc, AdPort, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    ApdComPort1: TApdComPort;
    procedure ApdComPort1TriggerAvail(CP: TObject; Count: Word);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Buffer: string[255];
  BufferIndex: Integer;


implementation

{$R *.dfm}

procedure TForm1.ApdComPort1TriggerAvail(CP: TObject; Count: Word);
var
  I: Word;
  C: Char;
begin
Buffer :=
  for I := 1 to Count do begin
    C := ApdComPort1.GetChar;
    if C = #7 then
      MessageBeep(0)
    else if C in [#32..#126] then begin
      Buffer := Buffer + C;
    end;
  end;
  edit1.text := buffer
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ApdComPort1.Open := True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
ApdComPort1.Open := False;
end;

end.
0
 
eagle00789Author Commented:
it works.
just one more question: how do i clear the buffer variable??

------

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OoMisc, AdPort, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    ApdComPort1: TApdComPort;
    procedure ApdComPort1TriggerAvail(CP: TObject; Count: Word);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Buffer: string[255];
  BufferIndex: Integer;


implementation

{$R *.dfm}

procedure TForm1.ApdComPort1TriggerAvail(CP: TObject; Count: Word);
var
  I: Word;
  C: Char;
begin
Buffer :=
  for I := 1 to Count do begin
    C := ApdComPort1.GetChar;
    if C = #7 then
      MessageBeep(0)
    else if C in [#32..#126] then begin
      Buffer := Buffer + C;
    end;
  end;
  edit1.text := buffer
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ApdComPort1.Open := True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
ApdComPort1.Open := False;
end;

end.
0
 
eagle00789Author Commented:
it works.
just one more question: how do i clear the buffer variable??

------

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OoMisc, AdPort, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    ApdComPort1: TApdComPort;
    procedure ApdComPort1TriggerAvail(CP: TObject; Count: Word);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Buffer: string[255];
  BufferIndex: Integer;


implementation

{$R *.dfm}

procedure TForm1.ApdComPort1TriggerAvail(CP: TObject; Count: Word);
var
  I: Word;
  C: Char;
begin
Buffer :=
  for I := 1 to Count do begin
    C := ApdComPort1.GetChar;
    if C = #7 then
      MessageBeep(0)
    else if C in [#32..#126] then begin
      Buffer := Buffer + C;
    end;
  end;
  edit1.text := buffer
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ApdComPort1.Open := True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
ApdComPort1.Open := False;
end;

end.
0
 
eagle00789Author Commented:
sorry for the multipost. made a mistake
0
 
rl912Commented:
Hello,

i do : Buffer := '';

0
 
eagle00789Author Commented:
ok. thx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now