Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : Range Check Error
| Subject: | Range Check Error |
| Posted by: | "voltage" (mich..@o2.pl) |
| Date: | Thu, 27 Jul 2006 10:50:28 |
Hi!
I wrote small program to receive data from RFID reader. Debug and
compilation process was fine but when I started it I received information
that "Range Check Error" occurs.
Is anyone know what could be a reason of this error?
I tried every possible variations and it helped but only a little. I do not
receive this error every time when I start software but problem still
exists.
I'm not a very good Delphi programmer so maybe I made some mistakes in this
code and this is the reason of my problems.
Michal
ps. }Rd!, }Cw, d:GCW, b:04, f:1 and other commands are correct and works
fine when I send them to reader using different software.
Software code:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, Math,
CheckLst;
type
TForm3 = class(TForm)
IdTCPClient1: TIdTCPClient;
Label1: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit3: TEdit;
Button1: TButton;
CheckBox1: TCheckBox;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
aLine, aLine1 : ansistring;
tr: boolean;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
if Button1.Caption='Disconnected' then
begin
with IdTCPClient1 do
begin
Host:=Edit1.Text;
Port:=strtoint(Edit3.Text);
Connect;
if IdTCPClient1.Connected then
begin
CheckBox1.Checked:=true;
Button1.Caption:='Connected';
end
else
showmessage('No Reader Found!');
end;
end
else
begin
IdTCPClient1.Disconnect;
Button1.Caption:='Disconnected';
CheckBox1.Checked:=false;
IdTCPClient1.IOHandler.Destroy;
end;
end;
procedure TForm3.Button2Click(Sender: TObject);
var
i: integer;
begin
if IdTCPClient1.Connected then
begin
tr:=true;
IdTCPClient1.IOHandler.WriteBufferOpen;
if Button4.Enabled=false then
begin
repeat
begin
IdTCPClient1.IOHandler.WriteBufferClear;
IdTCPClient1.IOHandler.WriteLn('}Rd!');
IdTCPClient1.IOHandler.ReadLnSplit(tr,#13#10,20,128);
aLine:=IdTCPClient1.IOHandler.ReadLnWait(10);
application.processmessages;
i:=Length(aline);
if i=42 then
begin
aLine1:=Copy(aLine, 7, 24);
Memo1.Lines.Add(aLine1);
end
else
end;
until Button3.Enabled=false
end
else
begin
tr:=true;
IdTCPClient1.IOHandler.WriteLn('}Rd!');
IdTCPClient1.IOHandler.ReadLnSplit(tr,#13#10,20,128);
aLine:=IdTCPClient1.IOHandler.ReadLn;
application.processmessages;
i:=Length(aline);
if i=42 then
begin
aLine1:=Copy(aLine, 7, 24);
Memo1.Lines.Add(aLine1);
end
else
end;
end;
end;
procedure TForm3.Button3Click(Sender: TObject);
begin
IdTCPClient1.IOHandler.WriteLn('}Cw, d:GCW, b:04, f:1!');
Button3.Enabled:=False;
Button4.Enabled:=True;
application.processmessages;
end;
procedure TForm3.Button4Click(Sender: TObject);
begin
IdTCPClient1.IOHandler.WriteLn('}Cw, d:GCW, b:07, f:1!');
Button4.Enabled:=false;
Button3.Enabled:=true;
application.processmessages;
end;
end.