Re: Gosh darn dag nab flabbergastrations!!!!!!!!
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Jul 24, 2000
- 456 views
------=_NextPart_000_028C_01BFF546.4E36E700 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable This is because=20 "if dt =3D 7 or 11" is interpreted as=20 "if (dt =3D 7) or (11 !=3D 0)" which is always true because 11 is = always not equal tro zero Instead, you might like to try "if dt =3D 7 or dt =3D 11" cheers, Derek Parnell dparnell at bigpond.net.au Melbourne, Australia ----- Original Message -----=20 From: A.R.S. Alvin Koffman=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Monday, July 24 2000 07:48 Subject: Gosh darn dag nab flabbergastrations!!!!!!!! Just when I think I might have a handle on this stuff my computer = yells STUPID!!! This code works, your a winner on 7 only, but look at the "if then" = test. Uncomment the or statement, and your a winner on everything. This = makes no sense!!!!! I'm no a smart man, but I (thought) know what an or = is for. I know this isn't proper code but I'm just trying to "get" = things right now. Alvin=20 =20 -- begin code -- A simple Windows dice game include win32lib.ew without warning ------------------------------------------ -- CONTROLS: constant WinDice =3D create( Window, "Win Dice!", 0, Default, Default, 400, 200, 0 ) -- create a control in the window constant Throw_Button =3D create( PushButton, "&Throw Dice", WinDice, 100, 30, 80, 40, 0 ) ---------------------------------------------- -- ACTIONS (things to do when initiating events occur): -- action to take when the window opens global procedure onPaint_WinDice( integer x1, integer y1, integer x2, integer y2 ) setPosition(WinDice,1,1) -- sets initial position for text wPuts( WinDice, "WinDice Version 1.0 Click the Throw dice button to = play" ) end procedure -- action to take when roll dice button pressed: procedure RollDice() integer d1,d2,dt d1 =3D rand( 6 ) -- get dice values d2 =3D rand( 6 ) dt =3D d1 + d2 repaintWindow(WinDice) -- clears screen so new numbers don't overwrite = old setPosition(WinDice,1,20) --sets position of first number wPrint(WinDice,d1) setPosition(WinDice,20,20)-- sets position of second number wPrint(WinDice,d2) setPosition(WinDice,40,20)-- sets position of second number wPrint(WinDice,dt) if dt =3D 7 -- or 11 then setPosition(WinDice,1,50) wPuts (WinDice, "**WINNER***") end if end procedure ----------------------------------------------- -- EVENTS (tell Windows when to do an action & what action to do): onPaint[WinDice] =3D routine_id( "onPaint_WinDice" ) onClick[Throw_Button]=3Droutine_id("RollDice") ----------------------------------------------- -- MAIN LOOP: -- hand control over to Windows WinMain( WinDice, Normal ) =20 -- end code http://ka9qlq.tripod.com/ ------=_NextPart_000_028C_01BFF546.4E36E700 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#a8c8f0> <DIV><FONT face=3DArial size=3D2>This is because </FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2><STRONG>"if dt =3D 7 or 11"</STRONG></FONT></DIV> <DIV><FONT face=3DArial size=3D2>is interpreted as </FONT></DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT size=3D2><STRONG>"if (dt =3D 7) or (11 !=3D = 0)" </STRONG> which=20 is always true because 11 is always not equal tro zero</FONT></DIV> <DIV> </DIV> <DIV>Instead, you might like to try</DIV> <DIV> <DIV><FONT size=3D2><STRONG>"if dt =3D 7 or dt =3D=20 11"</STRONG></FONT></DIV></DIV></FONT></DIV> <DIV> </DIV> <DIV>cheers,<BR>Derek Parnell<BR><A=20 lbourne,=20 Australia</DIV> <BLOCKQUOTE=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: = 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A href=3D"mailto:ka9qlq at HOTMAIL.COM" = title=3Dka9qlq at HOTMAIL.COM>A.R.S. Alvin=20 Koffman</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20 href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20 title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, July 24 2000 = 07:48</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Gosh darn dag nab=20 flabbergastrations!!!!!!!!</DIV> <DIV><BR></DIV> <DIV><FONT face=3DArial size=3D2>Just when I think I might have a = handle on this=20 stuff my computer yells STUPID!!!</FONT></DIV> <DIV><FONT face=3DArial size=3D2>This code works, your a winner = on 7 only,=20 but look at the "if then" test. Uncomment the or statement, and your a = winner=20 on everything. This makes no sense!!!!! I'm no a smart man, but I = (thought)=20 know what an or is for. I know this isn't proper code but I'm just = trying to=20 "get" things right now.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Alvin </FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>-- begin code</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- A simple Windows dice = game</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2><BR>include win32lib.ew</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>without warning</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial=20 size=3D2>------------------------------------------</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- CONTROLS:</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2><BR>constant WinDice =3D</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>create( Window, "Win Dice!", 0, = Default, Default,=20 400, 200, 0 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2><BR>-- create a control in the=20 window</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>constant Throw_Button = =3D</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>create( PushButton, "&Throw = Dice", WinDice,=20 100, 30, 80, 40, 0 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial=20 size=3D2>----------------------------------------------</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- ACTIONS (things to do when = initiating events=20 occur):</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2><BR>-- action to take when the window = opens</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>global procedure onPaint_WinDice( = integer x1,=20 integer y1, integer x2,<BR>integer y2 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>setPosition(WinDice,1,1) -- sets = initial position=20 for text</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>wPuts( WinDice, "WinDice Version 1.0 = Click the=20 Throw dice button to play" )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>end procedure</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- action to take when roll dice = button=20 pressed:</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>procedure RollDice()</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>integer d1,d2,dt</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>d1 =3D rand( 6 ) -- get dice = values</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>d2 =3D rand( 6 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>dt =3D d1 + d2</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2><BR>repaintWindow(WinDice) -- clears = screen so=20 new numbers don't overwrite old</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>setPosition(WinDice,1,20) --sets = position of=20 first number</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>wPrint(WinDice,d1)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>setPosition(WinDice,20,20)-- sets = position of=20 second number</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>wPrint(WinDice,d2)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>setPosition(WinDice,40,20)-- sets = position of=20 second number</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>wPrint(WinDice,dt)</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>if dt =3D 7 -- or=20 11<BR> then<BR> =20 setPosition(WinDice,1,50)<BR> wPuts (WinDice,=20 "**WINNER***")<BR> end if<BR>end procedure</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial=20 = <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- EVENTS (tell Windows when to do an = action=20 & what action to do):</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>onPaint[WinDice] =3D routine_id( = "onPaint_WinDice"=20 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial=20 size=3D2>onClick[Throw_Button]=3Droutine_id("RollDice")</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial=20 size=3D2>-----------------------------------------------</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- MAIN LOOP:</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2><BR>-- hand control over to = Windows</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>WinMain( WinDice, Normal = )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- end code</FONT></DIV> <DIV><FONT face=3DArial size=3D2><A=20 = ------=_NextPart_000_028C_01BFF546.4E36E700--