Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!njin!princeton!udel!burdvax!emerald!dave From: dave@emerald.PRC.Unisys.COM (David Lee Matuszek) Newsgroups: comp.sys.mac.programmer Subject: How do I read a line? Message-ID: <10387@burdvax.PRC.Unisys.COM> Date: 23 May 89 16:47:38 GMT Sender: news@PRC.Unisys.COM Organization: Unisys Corporation, Paoli Research Center; Paoli, PA Lines: 48 References: Dumb question time. I'm writing a program that interacts with the user via text input/output (no flames, please!). Logically, the program looks like: repeat write(Question); read(Answer); checkAnswer until done Now in reality, my program is an event loop, just like it should be. I have the windows & menus & mousing all working correctly, as well as the output. But how do I *read* the input line?? I don't want to use a Pascal "read" statement, because this stops the event loop until the read is completed. This prevents the user from using the menus, moving windows, and the like. Since the program will then do another "read" almost immediately, the Mac interface would be severely disabled. I don't want a modal dialog for the same reasons. My preference would be to have the user input (typing) go into the same text window that the program uses for output--just like on a terminal--and I'd get the line when the user hit Return. I think I could almost do this, if the user never backspaced, or used cut&paste. Maybe I'm making the problem to hard by trying to allow these things? It seems that I should be able to use a modeless dialog (just leaving it permanently on the screen). If I do, it would contain no text or anything, just a text entry field. I can't seem to figure out how to do this, either, and it would mean that the user had to continually look back and forth between two windows; but it would be better than nothing. It can't be this hard, can it? I worked through volume II of Chernikoff (old edition), and I typed in his editor and understood it and got it to work. So I know how to make random changes in the middle of a document. Somehow, though, I can't generalize enough to figure out how to READ IN A SINGLE LINE! What am I missing? Sample code would be wonderful, if you have something that does this (I'm using LSP, but I think I can read C well enough to translate). Suggestions would be gratefully accepted. -- Dave Matuszek (dave@prc.unisys.com) -- Unisys Corp. / Paoli Research Center / PO Box 517 / Paoli PA 19301 -- Any resemblance between my opinions and those of my employer is improbable. ** Fusion now! Remember the Exxon Valdez! **