another problem

new topic     » topic index » view thread      » older message » newer message

This is a multi-part message in MIME format.

------=_NextPart_000_0021_01C174DF.CE0BE6A0
	boundary="----=_NextPart_001_0022_01C174DF.CE0BE6A0"


------=_NextPart_001_0022_01C174DF.CE0BE6A0
	charset="iso-8859-1"

Now I want to add a score.  Currently the score (a) should go up by one every
time you answer a question correctly but when I look at the file score .txt it
prints...

<whatever the person put as their name>

...instead of a number.  There's probably a good reason whyt this happens but
being new to Euphoria I haven't spotted it.

Thanks!

Tom.

P.S:  I have attatched the program again, to make it work creat a blank file
called score.txt

------=_NextPart_001_0022_01C174DF.CE0BE6A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: 8bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4134.600" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Now I want to add a score.&nbsp; Currently the 
score (a)&nbsp;should go up by one every time you answer a question correctly 
but when I look at the file score .txt it prints...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&lt;whatever the person put as their 
name&gt;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>...instead of a number.&nbsp; There's probably a 
good reason whyt this happens but being new to Euphoria I haven't spotted 
it.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Tom.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>P.S:&nbsp; I have attatched the program again, to 

------=_NextPart_000_0021_01C174DF.CE0BE6A0
Content-Type: application/octet-stream;
	name="tomsquiz.ex"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="tomsquiz.ex"

--TOM'S QUIZ is made by Tom Harris of HOCUS POCUS
--HOCUS POCUS gAmEs

include get.e
include graphics.e
include file.e
include machine.e


integer i
integer a
integer q
sequence name
sequence highscore

a =3D 0


bk_color(WHITE)
text_color(BLUE)
allow_break(1)

--The questions begin

clear_screen()

puts(1, "What is the name of the current royal family?\n")
puts(1, "a. Tudor  b.Windsor  c.Stuart  d.Elizabeth\n")
    i =3D wait_key()
    if i !=3D 'b' and i !=3D 'B' then
if i =3D 'q' then
clear_screen()
puts(1, "Thankyou for playing!/n")
abort(0)
end if
	puts(1, "Sorry, that's the wrong answer!\n")

	abort(0)

    end if
  =20
clear_screen()

a =3D a+1
-- here we go again!
puts(1, "In what year did England win the world cup?\n")
puts(1, "a. 1996  b.1986  c.1976  d.1966\n")
    i =3D wait_key()
    if i !=3D 'd' and i !=3D 'D' then
if i =3D 'q' then
clear_screen()
puts(1, "Thankyou for playing!/n")
abort(0)
end if
	puts(1, "Sorry, that's the wrong answer!\n")

	abort(0)

    end if
clear_screen()
a =3D a+1
puts(1, "When did Steve Redgrave win his first gold medal?\n")
puts(1, "a. 2000  b. 1992  c. 1984  d. 1996\n")
    i =3D wait_key()
    if i !=3D 'c' and i !=3D 'C' then
if i =3D 'q' then
clear_screen()
puts(1, "Thankyou for playing!/n")
abort(0)
end if
	puts(1, "Sorry, that's the wrong answer!\n")

	abort(0)

    end if   =20

clear_screen()
a =3D a+1
puts(1, "How many times has cyclist Miguel Indurain won the 'Tour de =
France'\n")
puts(1, "a. 2  b. 3  c. 4  d. 5\n")
    i =3D wait_key()
    if i !=3D 'D' and i !=3D 'd' then
if i =3D 'q' then
clear_screen()
puts(1, "Thankyou for playing!/n")
abort(0)
end if
	puts(1, "Sorry, that's the wrong answer!\n")

	abort(0)

    end if =20

clear_screen() =20
a =3D a+1
integer file_num

constant ERROR =3D 2

file_num =3D open("score.txt", "u")
if file_num =3D -1 then
    puts(ERROR, "couldn't open highscore\n")

end if
name =3D prompt_string("Please enter your name :")
printf(file_num, "%s", {name})
printf(file_num, "%s", {a})
clear_screen()
puts(1, "You have been added to the highscore list.\n")



abort(0)



------=_NextPart_000_0021_01C174DF.CE0BE6A0--

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu