delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/19/17:01:47

From: mjara AT magus DOT cs DOT utah DOT edu (Michael Jara)
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro causes my program to crash?!
Date: 18 Jul 1998 23:13:19 GMT
Organization: University of Utah Computer Science Department
Lines: 78
Message-ID: <6ora6f$jnh@magus.cs.utah.edu>
NNTP-Posting-Host: lab1-12.eng.utah.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm writing a non-game with the assistance of Allegro, and I have
found that it is definitely faster and more versatile than GRX 2.0
(which I was using before).  However, since I converted everything to
allegro, I've had a problem:

Occasionally I send text to the printer, completely non-allegro
related.  If the printer is not turned on (or otherwise not ready),
windows alerts me of the fact and then my program crashes (windows
says something about illegal operations and such).  This ONLY happens
with allegro, it did not crash with GRX 2.0.

Since then I have written some short test programs which duplicate the
results.

With allegro:

#include <iostream.h>
#include <fstream.h>
#include <allegro.h>

int
main()
{
  allegro_init();
  set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);

  fstream printer("LPT1:", ios::out);

  for (int i=0; i<10; i++)
    printer << "testing " << i << endl;

  int var;
  cin >> var; // Don't exit until I give a signal

  printer.close();
}


And the GRX 2.0:

#include <iostream.h>
#include <fstream.h>
#include <grx20.h>

int
main()
{
  GrSetMode(GR_width_height_graphics, 640, 480, 256);

  fstream printer("LPT1:", ios::out);

  for (int i=0; i<10; i++)
    printer << "testing " << i << endl;

  int var;
  cin >> var;

  printer.close();
}


Now, you might be inclined to say "so don't use Allegro, use GRX 2.0".
However, #1: It took me forever to get my graphics and mouse routines
properly converted to allegro, #2: Allegro's mouse routines are MUCH
better than those of GRX 2.0, #3: I need to read and or write to more
than one com port at times (which I'm using DCcomm for).

Normally, this wouldn't be that big a deal, but my program is going to
be used by actual people, who won't like their program crashing if the
printer runs out of paper. :)

Any suggestions?
-- 
    _____   ___  ___  ___  ___  ______                                __
   /     | /   ||   ||   |/  / |    __|      mjara AT eng DOT utah DOT edu       \ \
  /      |/    ||   ||      /  |    _]  http://www.cs.utah.edu/~mjara  \ \
 /   /|        ||   ||       \ |   |____________________________________\ \
/___/ |____/ __||___||___|\___\|___________________________________________\ 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019