1. Re: EUPHORIA Digest - 18 Feb 1997 to 19 Feb 1997
- Posted by The Reaper <reaper at LOKI.ATCON.COM> Feb 20, 1997
- 1052 views
At 02:52 AM 2/20/97 -0500, you wrote: >I tried it without the quotes. When I double click on the icon, the screen >goes blank for a couple seconds, then returns to Windows Explorer without >starting the program. It runs OK with the quotes, but doesn't repeat. > >Steve Elder What's with the fancy while...loop procedures? Try my version below. (only two changes!!!) -------------------------------------------------------------------------------- -- 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() -- file hockey.ex -- reads in and prints team results. include dialog.e sequence team atom halt integer won, lost, tie, points while 1 do --endless loop team = prompt_in("\t Team: ") won = input("\t Won : ") lost = input("\t Lost: ") tie = input("\t Tie : ") points = won * 2 + tie puts(1,"\t Team \t \t Won Lost Tie Points \n\n") printf(1,"\t %-14s %3d %4d %3d %6d \n", {team} & won & lost & tie & points) halt = input ("\t Do another? 1 = yes 2 = no ") if halt != 1 then --checks whether you hit 1 or not exit end if end while -- EOF =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= The Reaper (J. Lays) reaper at auracom.com ........................ . .. -||..........__...... "There are no miracles, . / ||......../-- \\.:::: Just dreams that come true, . ..| ||...... / o o| |.::: By the actions of someone .| _-||.......|| ^ / /.:::: Who didn't waste time dreaming." ..| |..||...... -\_- \ |\-.::: .| |.[< \ .../ \.:: .||.|||\|\ | -REAPER- . \.:::: ...|.\|| | \ | | |.:::. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-