Board index » delphi » BGI error

BGI error

I have Turbo Pascal 7.0

When I run this code

program test;
uses crt,graph;
var gd,gm:integer;
begin
  gd:= detect;
  initgraph(gd,gm,'c:\tp\bgi');
  line(100,100,200,200);
end.

I have this error

BGI Error: Graphics not initialized (use InitGraph)

but I use this function. How can I do?

Thanks

    Tiziana

 

Re:BGI error


Quote
> program test;
> uses crt,graph;
> var gd,gm:integer;
> begin
>   gd:= detect;
>   initgraph(gd,gm,'c:\tp\bgi');
>   line(100,100,200,200);
> end.

> I have this error

> BGI Error: Graphics not initialized (use InitGraph)
> but I use this function. How can I do?

InitGraph may not switch to graphics due to some reasons. It is assumed a
good practice to get the return code of InitGraph as follows:

var Err;
....
InitGraph(gd,gm, 'c:\tp\bgi');
Err:=GraphResult;
if Err<>grOk then
  begin
    Writeln('Graphics error');
     Halt;
  end;
...

On error, GraphResult contains the error code. grOk means no error. You can
get the error description with GraphErrorMsg function.
Usually such errors occur due to wrong path to BGI drivers. Make sure that
your .BGI files are in C:\TP\BGI directory and correct the path if
necessary.

Ilja

Re:BGI error


Quote
Tan Hong Cheong wrote:

Are all the *.BGI files in the directory c:\tp\bgi ?
Quote
Tiziana Manfroni wrote:
> I have Turbo Pascal 7.0

> When I run this code

> program test;
> uses crt,graph;
> var gd,gm:integer;
> begin
>   gd:= detect;
>   initgraph(gd,gm,'c:\tp\bgi');
>   line(100,100,200,200);
> end.

> I have this error

> BGI Error: Graphics not initialized (use InitGraph)

> but I use this function. How can I do?

> Thanks

>     Tiziana

Other Threads