[comp.sys.amiga.tech] Waiting on Signals

haitex@pnet01.cts.com (Wade Bickel) (09/06/88)

        I'm trying to respond to some signals, and the code is not working
quite as I expected.  In the following code I'm trying to wait for two
possible signals and then respond to them...


        (*  In Benchmark Modula-2 *)

        PROCEDURE ProcSig(Sig : SignalSet);

          BEGIN
            IF CARDINAL(WIN^.UserPort^.mpSigBit) IN Sig THEN
              LOOP
                msg := GetMsg(WIN^.UserPort^);
                IF msg = NIL THEN EXIT; END;
                ProcIMsg(wp, msg);
                IF AllDone THEN RETURN; END;
              END; (* LOOP *)
            END; (* IF *)
            
            IF CARDINAL(UImsgPort^.mpSigBit) IN Sig THEN
              LOOP
                UI := GetMsg(UImsgPort^);
                IF UI = NIL THEN EXIT; END;
                ProcUImsg(UI);
                IF AllDone THEN RETURN; END;
              END;
            END;
   
          END ProcSig;

    
        BEGIN (* MAIN *)

          ...
          (* init code and startup checks ensure the msg port is working *)
          ...

          (* Make a window refrenenced by WIN *)

          ...

                AllDone := FALSE;
                WHILE NOT AllDone DO
                  sig := Wait(SignalSet{CARDINAL(WIN^.UserPort^.mpSigBit),
                                        CARDINAL(UImsgPort^.mpSigBit)});
                  ProcSig(sig);
                END; (* WHILE *)

          ...

          (* Cleanup *)

        END programname.


        Running the above code seems to work find except that in ProcSig()
the UImsgPort^.mpSigBit is never found to be in Sig.  By removing the check
to see if a UImsg has been received (and using GetMsg(UImsgPort^) returns
NIL to check) UImsgs are indeed found on the port, and it appears that the
signal from that source is what woke up the process.

        Any Ideas?  I'm new to Modula-2 sets (I used to work in assembly),
am I expressing this incorrectly?  Any other ideas?


                                                Thanks in advance...


                                                                Wade.

UUCP: {cbosgd, hplabs!hp-sdd, sdcsvax, nosc}!crash!pnet01!haitex
ARPA: crash!pnet01!haitex@nosc.mil
INET: haitex@pnet01.CTS.COM
Opionions expressed are mine, and not necessarily those of my employer.