Help wanted!
- Posted by Ad Rienks <Ad_Rienks at COMPUSERVE.COM> Feb 19, 1997
- 1049 views
-- file dialog.e -- enables simple text input and output include get.e include graphics.e global function input(sequence prompt) -- print a message and read in a number -- returns the number, that can either be an integer or an atom(float) sequence input, curpos input = {1, 0} -- this initializes the variable input with -- values that are *not* valid puts(1, prompt) -- put message on screen while input[1] do -- repeat until valid number curpos = get_position() -- read current cursor position input = get(0) -- read from the keyboard position(curpos[1], curpos[2]) -- back to position if not valid end while puts(1, '\n') -- to start on a new line when back from function return input[2] -- the second element of input is returned -- and should contain a valid number end function -- input() -- Input of a string with a prompt: global function prompt_in(sequence prompt) sequence in_string -- to read in the input puts(1, prompt) -- put prompt (question) on the screen in_string = gets(0) -- read string input from the keyboard puts(1, '\n') -- to start on a new line when back from function -- return the input string now, but strip off the last character, -- since that is a 'new line' character (ASCII 10) return in_string[1..length(in_string) - 1] end function -- prompt_in()