home *** CD-ROM | disk | FTP | other *** search
- {@@@@@@@@@@@ copyright (C) 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@@@@@@
- The purchaser of these procedures and functions may include them in COMPILED
- programs freely, but may not sell or give away the source text.
-
- This program is a simple demo of the use of POINTERS to produce
- a QUEUE. Please note that the amount of memory set aside for
- the QUEUE is ZERO. As each item is added, a chunk of memory is
- devoted to it. This is very often much more efficient than
- an ARRAY, which must be declared to be a specific size.
-
-
- }
-
-
- {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
- type
- ItemType = array[1..1016] of byte;
- {$I queue.lib}
- {$I kavail.lib}
- {$I getkeys.lib}
-
- var
- Klist, Kpointer : ListType;
- DummyItem : ItemType;
- N, Initial_K : integer;
- C, D : char;
- {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
- begin
- window(10,1,70,25);
- ClrScr;
- WriteLn('This program shows the effect of adding items to a queue.');
- WriteLn('After each addition, it shows the memory available in K');
- WriteLn('Since each item is one K in size (1016 bytes of data and');
- WriteLn('8 bytes for the pointer), additions are clearly visible.');
- WriteLn(' Each time you press a key, an item will be added. To');
- WriteLn('stop adding and dispose of all the items, press <Esc>');
- WriteLn;
- Initial_K := K_Available;
- WriteLn('You start with ',K_available,'K available.');
- window(10,10,70,25);
- for N := 1 to 1016 do
- DummyItem[N] := N and $00FF; { I have heard that for reducing an }
- { integer to a byte, "and $00FF" is }
- { much faster than "mod 256". }
- N := 0;
- repeat
- GetKeys(C,D);
- N := N + 1;
- AddItem(DummyItem,KList,KPointer);
- WriteLn('Added ',N,' items. ',K_available,'K available.');
- until (C = #27) and (D = #0);
- WriteLn;
- WriteLn('You started with ',Initial_K,'K bytes.');
- WriteLn('After adding ',N,' items, you have ',K_available,'K bytes.');
- WriteLn;
- DisposeAll(KList);
- WriteLn('I just DISPOSEd of the list. You have ',K_available,'K bytes.');
- end.
-