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
| DOS | UNIX | Windows | ANSI C | C++ 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.
| Error | graphics_errors | |
| code | constant | Corresponding error message string |
| 0 | grOk | No error |
| -1 | grNoInitGraph | (BGI) graphics not installed (use initgraph) |
| -2 | grNotDetected | Graphics hardware not detected |
| -3 | grFileNotFound | Device driver file not found |
| -4 | grInvalidDriver | Invalid device driver file |
| -5 | grNoLoadMem | Not enough memory to load driver |
| -6 | grNoScanMem | Out of memory in scan fill |
| -7 | grNonoodMem | Out of memory in flood fill |
| -8 | grFontNotFound | Font file not found |
| -9 | IgrNoFontMem | Not enough memory to load font |
| -10 | grInvalidMode | Invalid graphics mode for selected driver |
| -11 | grError | Graphics error |
| -12 | grIOerror | Graphics I/O error |
| -13 | grInvalidFont | Invalid font file |
| -14 | grInvalidFontNum | Invalid font number |
| -15 | grInvalidDeviceNum | Invalid 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. | grInvalidVersion | Invalid 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
detectgraphdrawpolyfillpolyfloodfillgrapherrormsginitgraphpiesliceregisterbgidriverregisterbgifontsetallpalettesetcolorsetfillstylesetgraphmodesetlinestylesetpalettesettextjustifysettextstylesetusercharsizesetviewportsetvisualpage
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.
Stable link: /3.1/graphics.h/graphresult/
· short form /3.1/graphresult/