Category : Files from Magazines
Archive   : ISSUE-33.ZIP
Filename : PASCAL.FIG

 
Output of file : PASCAL.FIG contained in archive : ISSUE-33.ZIP

Program LIFOdemo;
const
qsize = 20;

var
queue : array [0..qsize] of char; { must be global vars since can be }
qptr : 0..qsize; { asynchronously updated }
ch2, ch3 : char;


function PutOnQ (ch:char):boolean;
begin
if succ(qptr) > qsize then { queue full? }
PutOnQ := false { yes, signal failure }
else begin
qptr := succ(qptr); { not full, update pointer & add data }
queue[qptr] := ch;
PutOnQ := true;
end;
end;

function GetFromQ (var ch:char):boolean;
begin
if qptr = 0 then { queue empty? }
GetFromQ := false { yes, signal failure }
else begin
ch :=queue[qptr]; { else get data & update pointer }
qptr := pred(qptr);
GetFromQ := true;
end;
end;

procedure ProcessInput (ch:char); { not really much processing here! }
begin
write(ch);
end;


begin
qptr := 0;
ch2 := '@'; { pred('A') }

repeat
ch2 := succ(ch2);

{ the following statement is to demonstrate the effects of async removal }
{ if random(10) > 3 then
if GetFromQ(ch3) then ProcessInput(ch3); }

until not(PutOnQ(ch2));

while GetFromQ(ch2) do
ProcessInput(ch2);
end.

{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

Program FIFOdemo;

const
qsize = 20;

var
queue : array [0..qsize] of char; { must be global vars }
q_top_ptr, q_bot_ptr : 0..qsize;
ch2, ch3 : char;


function PutOnQ (ch:char):boolean;
begin
if succ(q_bot_ptr) mod (qsize + 1) = q_top_ptr then { queue full? }
PutOnQ := false { if yes, can't add }
else begin
q_bot_ptr := succ(q_bot_ptr) mod (qsize + 1); { update bottom pointer }
queue[q_bot_ptr] := ch; { store the data }
PutOnQ := true; { signal success }
end;
end;

function GetFromQ (var ch:char):boolean;
begin
if q_top_ptr = q_bot_ptr then { queue empty? }
GetFromQ := false { if yes, then nothing to get }
else begin
q_top_ptr := succ(q_top_ptr) mod (qsize + 1); { update top pointer }
ch := queue[q_top_ptr]; { get the data }
GetFromQ := true; { signal success }
end;
end;

procedure ProcessInput (ch:char); { not a lot of processing here! }
begin
write(ch);
end;


begin { Program FIFO }
q_top_ptr := 0; { initialize pointers }
q_bot_ptr := 0;
ch2 := '@'; { pred ('A') for demo }

repeat
ch2 := succ(ch2); { bump input data }

{ the following statement is to show asynchronous removal }
{ if random(10) > 3 then
if GetFromQ(ch3) then ProcessInput(ch3); }

until not(PutOnQ(ch2));

while GetFromQ(ch2) do
ProcessInput(ch2);
end.




  3 Responses to “Category : Files from Magazines
Archive   : ISSUE-33.ZIP
Filename : PASCAL.FIG

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/