Path: utzoo!attcan!uunet!mcvax!enea!kth!draken!duvan!drs-ano
From: drs-ano@duvan.nada.kth.se (Gunnar Nordmark)
Newsgroups: comp.sys.amiga
Subject: Re: Using Software Interrupts for Menu Handling
Summary: CMD_FLUSH doesn't seem to generate an error.
Message-ID: <430@draken.nada.kth.se>
Date: 26 Jun 88 12:58:10 GMT
References: <8806212054.AA00815@cory.Berkeley.EDU>
Sender: news@nada.kth.se
Reply-To: G@epsilon.stacken.kth.se (Gunnar Nordmark)
Organization: The Royal Inst. of Techn., Stockholm
Lines: 51

In article <8806212054.AA00815@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU (Matt Dillon) writes:
>	close ??  CMD_FLUSH is what you meant.  I haven't tried this, but
>it ought to work.  The nice thing about using CMD_FLUSH is that you can do
>it multiple times.
>
>	CLOSEing the file handle would probably crash the machine!  In
>fact, sending any DOS packet from a software interrupt might crash the 
>machine because DOS can only handle waiting for one response at a time
>(because it expects the returned packet to be the first msg on the port).
>
>					-Matt

Good idea!  But it doesn't work, don't ask me why. RKM (AW page 45) states
that a CMD_FLUSH will return all pending I/O requests with an error,
but what happens in this case is that you get a copy of the last character
typed. An example:

First you do a
  fgets(buf, stdin);
this function will not return until it has collected a full line of text.
Then Charlie User starts typing some characters
  Hi, mom
Suddenly he gets restless and begins to play with the menus, he selects
  QUIT
This causes a softint that does
  finito=YES;
  ioreq->io_Command=CMD_FLUSH;
  ioreq->io_Device=conDevice;
  ioreq->io_Unit=(struct Unit *)conUnit;
  DoIO(ioreq);
However, the fgets() doesn't return. Instead a copy of the last character
typed appears on the screen.
  Hi, momm
The effect is exactly the same as if he had retyped the last character.

I haven't digged into the depths of the fgets() function, but I suspect the
problems lies in the CON: handler. I'm using ConMan 1.1 but I will try it
on a plain CON: to see if it behaves differently.

In any case this approach *ought to* work, (right Matt?), and I won't *ever*
give up my idea of letting software interrupts abort readrequests.
If I get it working, it will be possible to Intuitionize software written
for other computers with very little effort. You just call a customized
error-handling routine when a read-error occurs (which you would probably
do anyway) and that routine handles menus and gadgets for you.
A modular and elegant approach!

SNAIL: Gunnar Nordmark          VOICE: (+46) 8 - 755 42 52
       Nora strand 5
       S-182 34 DANDERYD        EMAIL: G@epsilon.stacken.kth.se
       SWEDEN                          nordmark@vaxkab.sunet.se