Borland C++ reference

graphresult

raw OCR

Returns an error code for the last unsuccessful graphics operation.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
int far graphresult(void);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

graphresult returns the error code for the last graphics operation that reported an error and resets the error level to grOk.

The following table lists the error codes returned by graphresult. The enumerated type graph_errors defines the errors in this table. graph_errors is declared in graphics.h.

Errorgraphics_errors
codeconstantCorresponding error message string
0grOkNo error
-1grNoInitGraph(BGI) graphics not installed (use initgraph)
-2grNotDetectedGraphics hardware not detected
-3grFileNotFoundDevice driver file not found
-4grInvalidDriverInvalid device driver file
-5grNoLoadMemNot enough memory to load driver
-6grNoScanMemOut of memory in scan fill
-7grNonoodMemOut of memory in flood fill
-8grFontNotFoundFont file not found
-9IgrNoFontMemNot enough memory to load font
-10grInvalidModeInvalid graphics mode for selected driver
-11grErrorGraphics error
-12grIOerrorGraphics I/O error
-13grInvalidFontInvalid font file
-14grInvalidFontNumInvalid font number
-15grInvalidDeviceNumInvalid device number
-18 Note that the variable maintained by graphresult is reset to 0 after graphresult has been called. Therefore, you should store the value of graphresult into a temporary variable and then test it.grInvalidVersionInvalid version number

Return value

graphresult returns the current graphics error number, an integer in the range -15 to 0; grapherrormsg returns a pointer to a string associated with the value returned by graphresult.

See also

Example

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)

   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();

   if (errorcode != grOk) {  /* an error occurred  */
      printf("Graphics error: %s\n", grapherrormsg (errorcode));
      printf( "Press any key to halt:");
      getchO ;
      exit (1);              /* terminate with an error code  */
   }
   /* draw a line */
   line(0, 0, getmaxx(   getmaxy (

   /* clean up */
   getchO ;
   closegraphO ;
   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.