1. Another printf question
- Posted by Bob Hancock <bob at SPEED.NET> Nov 10, 1997
- 594 views
- Last edited Nov 11, 1997
I'm trying to modify the example for the "gets" command (from the Library Routines manual) to accept multiple lines of text from the Keyboard; and then to print the material back to the screen, using printf (or puts). I sometimes get complete system crashes. The example in the manual is (after declaring "line" as OBJECT, and "buffer" as SEQUENCE ): while 1 do if atom(line) then exit end if buffer = append(buffer, line) end while ========= My modified version for Inputting text is: ============= puts(1, "Type in some text ... \n") while 1 do line = gets(0) if match(line, "\n\n") then exit end if buffer = append(buffer, line) end while ========= I'm trying to stop the Entry of text at the keyboard with a Double CR ("\n\n"). I think it's working, but I'm not able to print the buffer back to the screen to see it. Can anyone finish off this little project for me?? Thanks, -- Bob Hancock -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Bob Hancock ... ======>bob at speed.net<======== Irvine, CA
2. Re: Another printf question
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Nov 10, 1997
- 562 views
- Last edited Nov 11, 1997
Bob Hancock wrote: > > I'm trying to modify the example for the "gets" command (from the Library > Routines manual) to accept multiple lines of text from the Keyboard; and > then to print the material back to the screen, using printf (or puts). I > sometimes get complete system crashes. > My modified version for Inputting text is: > ============= > > puts(1, "Type in some text ... \n") > while 1 do > line = gets(0) > if match(line, "\n\n") then > exit > end if > buffer = append(buffer, line) > end while > ========= > > I'm trying to stop the Entry of text at the keyboard with a Double CR > ("\n\n"). I think it's working, but I'm not able to print the buffer back > to the screen to see it. > > Can anyone finish off this little project for me?? It's almost there, the only problem is the append function. Append puts the new line sequence as the last element of the buffer sequence. This crashes the puts statment, which expects a sequence of character atoms, not multiple sequences. The fix is easy, use "buffer = buffer & line" in place of the append. > Thanks, -- Bob Hancock > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > Bob Hancock ... ======>bob at speed.net<======== > Irvine, CA You're welcome. -- _____ _____ _____ ________ /\ \ /\ \ /\ \ / \ \ / \____\ / \____\ / \____\ / _ \____\ / / ___/_ / /____/ / / ___/_ / / \ |___| / / /\____\ / \ \ / / /\____\ \ \_/ / / \ \/ / ___/_\ \ \ \ \/ / ___/_ \ /____/ \ / /\ \\/\ \ \ \ / /\ \ \ \ \ \ \/ \____\ \ \ \ \ \/ \____\ \ \ \ \ / / \ \____\ \ / / \ \____\ \ / / \ / / \ / / \ / / \ / / \/____/ \ / / \/____/ \/____/xseal at harborside.com\/____/