Computer Science Canada

procedure and else if statements

Author:  sci23 [ Thu Dec 20, 2007 4:26 pm ]
Post subject:  procedure and else if statements

when i run this there is an error. how do i put else if statements in procedures? thanks for your help
code:


procedure die
if die=die1 then
drawbox(300,50,200,150,7)
drawfilloval(250,100,10,10,7)
elsif
 die=die2 then
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
elsif
die=die3 then
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(250,100,10,10,7)
elsif
die=die4 then
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(285,65,10,10,7)
drawfilloval(215,135,10,10,7)
elsif
die=die5 then
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(285,65,10,10,7)
drawfilloval(215,135,10,10,7)
drawfilloval(250,100,10,10,7)
elsif
die=die6 then
drawbox(300,50,200,150,7)
drawfilloval(285,135,10,10,7)
drawfilloval(215,65,10,10,7)
drawfilloval(285,65,10,10,7)
drawfilloval(215,135,10,10,7)
drawfilloval(215,100,10,10,7)
drawfilloval(285,100,10,10,7)
end if
end die

put "Rolled ", Rand.Int (die,1, 6)

Author:  Saad [ Thu Dec 20, 2007 5:07 pm ]
Post subject:  RE:procedure and else if statements

What exactly are you trying to do?, as far as i know, you cant check if procedures are equal (Why would you anyway?)

Author:  Jestar [ Thu Dec 20, 2007 5:41 pm ]
Post subject:  Re: procedure and else if statements

i would just make a different procedure for each die roll and call the procedure when it has the correct die roll.

Author:  Clayton [ Thu Dec 20, 2007 6:11 pm ]
Post subject:  RE:procedure and else if statements

Why not create one procedure which takes a parameter for which value the die has been rolled?

Author:  Jestar [ Thu Dec 20, 2007 8:11 pm ]
Post subject:  Re: procedure and else if statements

that works to Very Happy


: