home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
pascal
/
library
/
dos
/
multtsk
/
cpm25d
/
taskwin.pas
< prev
Wrap
Pascal/Delphi Source File
|
1994-04-28
|
3KB
|
128 lines
{$I cpmswitc.inc}
{--------------------------------------------------------------------------
TASKWIN.PAS (Demo: Code sharing)
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 demo program illustrates how code sharing between tasks
can be achieved very simply.
---------------------------------------------------------------------------}
program TaskWindows;
uses CRT, CPMulti;
type WinType = record
Top,
Left,
Bottom,
Right : word;
end;
const NoWin = 8;
TaskWin : array[1..8] of WinType =
((Top:2;Left:5;Bottom:9;Right:15),
(Top:2;Left:25;Bottom:9;Right:35),
(Top:2;Left:45;Bottom:9;Right:55),
(Top:2;Left:65;Bottom:9;Right:75),
(Top:12;Left:5;Bottom:19;Right:15),
(Top:12;Left:25;Bottom:19;Right:35),
(Top:12;Left:45;Bottom:19;Right:55),
(Top:12;Left:65;Bottom:19;Right:75));
var Screen : Pointer;
TaskNo : Word;
{---------------------------------------------------------------------------}
procedure Frame (X1,Y1,X2,Y2:Byte);
var N : Byte;
begin
SemWait(Screen);
Window(1,1,80,25);
GotoXY(X1,Y1);
Write('╔');
for N := 1 TO X2-X1-1 do
Write('═');
Write('╗');
for N := 1 TO Y2-Y1-1 do
begin
GotoXY(X1,Y1+N);
Write('║');
GotoXY(X2,Y1+N);
Write('║');
end;
GotoXY(X1,Y2);
Write('╚');
for N := 1 TO X2-X1-1 do
Write('═');
Write('╝');
SemSignal(Screen);
end;
{---------------------------------------------------------------------------}
{$F+}
procedure SubTask(TaskNo:Pointer);
var MyNo : Word;
Pass : Word;
begin
MyNo := Word(TaskNo);
Pass := 1;
with TaskWin[MyNo] do
Frame(Left-1,Top-1,Right+1,Bottom+1);
repeat
SemWait(Screen);
with TaskWin[MyNo] do
begin
Window(Left,Top,Right,Bottom);
GotoXY(2,8);
Writeln('--',Pass:4,' --');
Inc(Pass);
end;
SemSignal(Screen);
Sleep(Random(Seconds(1)));
until False;
end;
{$F-}
{---------------------------------------------------------------------------}
begin
ClrScr;
GotoXY(20,23);
Writeln('Press any key to exit...');
if (CreateSem(Screen) <> Sem_OK) then
begin
Writeln('Error in creating semaphore!');
Halt(1);
end;
SemClear(Screen);
for TaskNo := 1 to NoWin do
if CreateTask(SubTask,Pointer(TaskNo),Pri_User,500) < 0 then
begin
Writeln(^G'Error in creating task ',TaskNo);
Halt(1);
end;
SemSignal(Screen);
repeat
Sleep(Seconds(1));
until Keypressed;
SemWait(Screen);
Window(1,1,80,25);
GotoXY(1,23);
end.