" Code written by Jim Holehouse " Object subclass: #Prompter instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: nil ! Prompter comment: 'I prompt a user to enter a string on stdin' ! " for example ...the following " "|x| x := Prompter prompt: 'hello ' default: 'world'. x printNl !" !Prompter class methodsFor: 'input' ! prompt: aPrompt default: aDefault | result | aPrompt print. result := self readNl: stdin. (result size == 0) ifTrue: [result := aDefault]. ^ result ! readNl: input | output char | "input := ReadStream on: 'a test string'" output := WriteStream on: (String new: 0). char := input next. [char == Character nl] whileFalse: [ output nextPut: char. char := input next. ]. ^ output contents !!