home *** CD-ROM | disk | FTP | other *** search
- Program Servant;
-
- Uses
- CRT,
- Graph;
-
- Const
- FileName = 'F:\DATA.DAT';
-
- Type
- arType = Array [1..5] of Word;
-
- Var
- f : File Of arType;
- a : arType;
- gd, { For graphics }
- gm : Integer; { " }
- loop, { General purpose variable }
- pieSeg, { Used to hold size of pie segment }
- sub, { Used to track total angle size }
- total : Word; { Used to hold the sum of the array }
-
- Begin
- gd := Detect; { Use Auto detect }
- InitGraph ( gd, gm, '' ); { Initialize the graphics }
- If ( GraphResult <> grOk ) Then
- Begin { If graphics error, halt }
- WriteLn ( GraphResult );
- Halt;
- End;
- Assign ( f, FileName );
- FileMode := 64; { Access Read Only - Deny None }
- Repeat
- {$I-}
- Reset ( f ); { Loop until the file exists, this }
- loop := IOResult; { will make Servant wait until Master }
- {$I+} { has started running. }
- Until ( loop = 0 );
- Repeat
- Seek ( f, 0 ); { Move to start of the file }
- Read ( f, a ); { Read the information }
-
- sub := 0; { Initialize values }
- total := 0; { " }
- For loop := 1 to 5 Do
- total := total + a[loop]; { Calculate total }
- For loop := 1 to 5 Do
- Begin
- SetFillStyle ( SolidFill, loop ); { Set a unique color }
- pieSeg := Round ( ( a[loop] / total ) * 360 );
- If ( pieSeg + sub > 360 ) Then { Make sure we do not go over }
- pieSeg := 360 - sub; { 360 degrees. }
- PieSlice ( GetMaxX div 2, GetMaxY div 2, sub, sub + pieSeg,
- GetMaxY div 2 - 20 ); { Draw pie slice }
- sub := sub + pieSeg;
- End;
- Until KeyPressed; { Stop on user input }
- Close ( f ); { Close the file }
- CloseGraph;
- End.
-