home *** CD-ROM | disk | FTP | other *** search
- Program BgiSampleOne;
- {----------------------------------------------------------------------}
- { This is the first sample program using the BGI of Turbo Pascal. It }
- { is intended as a general introduction to the BGI's capabilities. }
- {----------------------------------------------------------------------}
-
- Uses Crt, Graph; { Link in the Crt and Graph units }
-
- Const
- PathToDrivers = ''; { Used to tell InitGraph where to find its }
- { necessary support files }
- GraphModeMsg = 'System is now in GRAPHICS MODE!';
- { Message to be outputted when in graph mode }
- ExitProgramMsg = 'Press any key to exit program........';
-
- Var
- GraphDriver,
- GraphMode : Integer; { Variables to pass to InitGraph }
- GrErr : Integer; { State of Graphics System. }
- Ch : Char; { Temporary variable for Readkey }
-
- Begin
- GraphDriver := Detect; { Request Auto Detection of Graphics Mode }
- InitGraph( GraphDriver, GraphMode, PathToDrivers );
- { Initialize the Graphics Mode }
- GrErr := GraphResult; { See if an error occurred, and act on it }
- If( GrErr <> grOk ) Then
- Begin
- Writeln( 'An error has occurred - ', GraphErrorMsg( GrErr ) );
- Writeln( ExitProgramMsg );
- Ch := Readkey;
- Halt( 1 );
- End;
- Rectangle( 0,0,GetMaxX,GetMaxY );
- { Places a border around the screen }
- MoveTo( 5,5 ); { Update Current Pointer to reflect border }
- OutText( GraphModeMsg );{ Output the graphics message }
- MoveTo( 5, 5 + TextHeight( GraphModeMsg) );
- { Update Current Pointer for mext message }
- OutText( ExitProgramMsg );{ Output exitting message }
- Ch := Readkey; { Pause until a key is pressed }
- CloseGraph; { Shut down BGI and graphics mode }
- End.