Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!texbell!sugar!peter From: peter@sugar.hackercorp.com (Peter da Silva) Newsgroups: comp.sys.amiga.tech Subject: Re: window/event/conman questions Message-ID: <4688@sugar.hackercorp.com> Date: 7 Dec 89 13:06:02 GMT References: <29800002@inmet> Reply-To: peter@sugar.hackercorp.com (Peter da Silva) Organization: Sugar Land Unix - Houston Lines: 62 In article <29800002@inmet> rich@inmet.inmet.com writes: > I am writing a programming environment (a smalltalk that is derived from > Tim Budd's Little Smalltalk, but faster) for Ami. Cool. > w = OpenWindow(...); > for (;;) > { > if (!(msg = GetMsg(w->UserPort))) > WaitPort(w->UserPort); > else if (handleEvent(msg)) > break; > } First of all, do this: for(;;) { if(msg = GetMsg(w->UserPort)) if(handleEvent(msg)) break; if(!msg) Wait(1<UserPort->mp_SigBit); } > What happen if a program opens multiple windows and each one ants to wait > for some events? How does one code that? Say you have a null-terminated array of windows, w: bits = 0; for(i = 0; w[i]; i++) bits |= 1<UserPort->mp_SigBit; for(;;) { for(i = 0; w[i]; i++) if(msg = GetMsg(w->UserPort)) { if(handleEvent(msg)) goto break2; break; } if(!msg) wait(bits); } break2: /* So sue me for using a goto. I wanted to make it match his code * pretty closely. This was the cleanest way. */ > Finally, I am using ConMan's feature of opening a window as a file handle > by calling Open() with file name "con:wXXXX" where XXXX is the address of > the opened window. Please don't do this. There are ways of attaching a console device to a window, and I'm sure that someone will come up with one for you. If you depend on ConMan, you'll be unable to run your program on any system that doesn't have it. For something like Smalltalk, that'd be too bad. -- Peter "Have you hugged your wolf today" da Silva `-_-' 'U` "Really, a video game is nothing more than a Skinner box." -- Peter Merel