1. Hockey.ex
Here's what I have so far. I added the while loop to hockey.ex to stop the
program from instantly dumping out under Windows 95, but the yes/no input
doesn't yet work. Any ideas?
-- 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()
--EOF
-- file hockey.ex
-- reads in and prints team results.
include dialog.e
sequence team
atom halt
integer won, lost, tie, points
halt = '1'
while halt = '1' do
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 ")
end while
-- EOF
2. Hockey.ex
On february 19, Steve Elder wrote:
>---------------------- Information from the mail header
-----------------------
>Sender: Euphoria Programming for MS-DOS
<EUPHORIA at MIAMIU.ACS.MUOHIO.EDU>
>Poster: Steve Elder <SteveElde at AOL.COM>
>Subject: Hockey.ex
>--------------------------------------------------------------------------
-----
>Here's what I have so far. I added the while loop to hockey.ex to stop
the
>program from instantly dumping out under Windows 95, but the yes/no input
>doesn't yet work. Any ideas?
Hi Steve. The variable halt is declared as an atom (could be an integer),
and the function input
also returns an atom (or an integer). So to test the value of halt you need
to test for an integer.
This means you have to write: while halt = 1 do, without quotes around the
1.
I think this will help.
Ad.
3. Re: Hockey.ex
>but the yes/no
>input
>doesn't yet work. Any ideas?
>halt = '1'
>
>while halt = '1' do
>
> halt = input ("\t Do another? 1 = yes 2 = no ")
>
>end while
Make halt a sequence not an atom AND
sequence halt
--atom halt
Use double quotes "1" not single quotes '1'.
Problem should be solved.
OR if you are Truly returning numbers AND NOT
ascii value of numbers such as Ascii for 1 is 49
then leave as an atom and use 1 not '1'
MEANING remove the single quotes.
--Lucius Lamar Hilley III
-- E-mail at luciuslhilleyiii at juno.com
-- I can only support file transfers of less than 64K and in UUE format.