home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
library
/
dos
/
multtsk
/
cpm25d
/
quetest.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-04-28
|
3KB
|
113 lines
{$I cpmswitc.inc}
{--------------------------------------------------------------------------
QUETEST.PAS (Test program for the Queue unit)
This program requires the CPMULTI Multitasking Toolkit and Turbo Pascal
5.0 or later.
January 1994
Copyright (C) 1994 (USA) Copyright (C) 1989-1994
Hypermetrics Christian Philipps Software-Technik
PO Box 9700 Suite 363 Duesseldorfer Str. 316
Austin, TX 78758-9700 D-47447 Moers
Germany
This is a demo of the Queue unit; it allows the user to enter
a list of strings into a queue and then delete selected elements
from the queue.
---------------------------------------------------------------------------}
program QueueTest;
uses Queue;
type MyRecType = record
Num : Byte;
T : string;
end;
MyPtrType = ^MyRecType;
var MyQueue : QueueType;
MyPtr : MyPtrType;
Work : string;
Count : Byte;
N : Byte;
{$F+}
function Compare(V,D:Pointer):Boolean;
var BPtr : ^Byte absolute V;
MPtr : MyPtrType absolute D;
begin
Compare := (MPtr^.Num = BPtr^);
end;
{$F-}
{$F+}
function Compare1(V,D:Pointer):Boolean;
var SPtr : ^String absolute V;
MPtr : MyPtrType absolute D;
begin {Compare1}
Compare1 := (MPtr^.T = SPtr^);
end;
{$F-}
procedure DisplayQueue;
var N : Byte;
Z : MyPtrType;
begin
for n := 1 TO Count do
begin
Z := MyPtrType(FindRec(MyQueue,@n,Compare));
if Z <> nil then
Writeln(Z^.Num:3,' ',Z^.T);
end;
end;
begin
Count := 0;
CreQueue(MyQueue);
repeat
Write('Please enter text: ');
Readln(Work);
if Byte(Work[0]) > 0 then
begin
New(MyPtr);
Inc(Count);
with MyPtr^ do
begin
T := Work;
Num := Count;
end;
AppendRec(MyQueue,MyPtr);
end;
until Byte(Work[0]) = 0;
Writeln('You have entered',Count,' elements!');
Writeln('Here they are...');
DisplayQueue;
Writeln;
Writeln('Remove individual elements...');
repeat
Write('Remove element with text: ');
Readln(Work);
if Byte(Work[0]) > 0 then
begin
MyPtr := MyPtrType(FindRec(MyQueue,@Work,Compare1));
if MyPtr = nil then
Writeln('Element not found!')
else
begin
if RemoveRec(MyQueue,MyPtr) = nil then
{ Do nothing } ;
Dispose(MyPtr);
DisplayQueue;
Writeln;
end;
end;
until Byte(Work[0]) = 0;
end.