Re: TZF - seeking in a VirtualFile
gerard sylvan <[email protected]> Mon, 16 Jun 2003 22:16:12 +0200
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'll send you a small program which make use of seek & peek in a
TzVFile.
The code is something like this one:
procedure TForm1.Btn1Click(Sender: TObject);
var s: String;
Begin
s := LPad (SysUtils.Trim (ed.Text), 4);
with Vf do
if (s <> '') and (Active) then
begin
GoTop;
while not dEof do
begin
if GetField ('REF') = s then
Break;
Skip (1);
end;
if dEof then
Lbl.Caption := 'NO !'
else
Lbl.Caption := 'YES !';
end;
End;
procedure TForm1.Btn2Click(Sender: TObject);
var s: String;
n, MaxRec: LongInt;
Ok: Boolean;
Begin
Ok := False;
s := LPad (SysUtils.Trim (ed.Text), 4);
with Vf do
if (s <> '') and (Active) then
begin // no need for "GOTOP"
MaxRec := RecCount;
for n := 1 to MaxRec do
if Peek (1, n) = s then
begin
Go (n);
Ok := True;
Break;
end;
if Ok then
Lbl.Caption := 'YES !'
else
Lbl.Caption := 'NO !';
end;
End;
procedure TForm1.Btn3Click(Sender: TObject);
var s: String;
Begin
s := Pad (Upper (SysUtils.Trim (ed.Text)), 30);
with Vf do
if (s <> '') and (Active) then
begin
GoTop;
while not dEof do
begin
if Upper (GetField ('NAME')) = s then
Break;
Skip (1);
end;
if dEof then
Lbl.Caption := 'NO !'
else
Lbl.Caption := 'YES !';
end;
End;
procedure TForm1.Btn4Click(Sender: TObject);
var s: String;
n, MaxRec: LongInt;
Ok: Boolean;
Begin
Ok := False;
s := Pad (Upper (SysUtils.Trim (ed.Text)), 30);
with Vf do
if (s <> '') and (Active) then
begin // no need for "GOTOP"
MaxRec := RecCount;
for n := 1 to MaxRec do
begin
if Upper (Peek (2, n)) = s then
begin
Go (n);
Ok := True;
Break;
end;
end;
if Ok then
Lbl.Caption := 'YES !'
else
Lbl.Caption := 'NO !';
end;
End;
Btn1 & Btn2 seek on a numeric field and Btn3 & 4 seek on a character field.
Gerard.
==^================================================================
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]
TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
==^================================================================