
-----------------------------------
kasi
Tue Nov 20, 2007 8:09 pm

how to continue a program after a loop
-----------------------------------
i have figured out the button, but i just have one more problem after the loop the "Enter the number of the first die you have rolled:" doesn't get outputted, how would i program it so the "Enter the number of the first die you have rolled:" get outputted 





import GUI 
procedure di2 
var die : array 1 .. 6 of procedure dice 

die (1) := die1 
die (2) := die2 
die (3) := die3 
die (4) := die4 
die (5) := die5 
die (6) := die6 

die (Rand.Int (1, 6)) 


var d : array 1..6 of procedure dice 
d(1):= d1 
d(2):= d2 
d(3):= d3 
d(4):= d4 
d(5):= d5 
d(6):= d6 
d (Rand.Int (1, 6)) 
end di2 

procedure dice 
locate(1,1) 
end dice 

var dice1:int 
put"If you want to play dice click on the button below" 

dice1:=GUI.CreateButton(25,25,0,"Click to roll the dice",di2) 



loop 
exit when GUI.ProcessEvent 
end loop 

 var diee,dce,total,num1,num2:int 
put"Enter the number of the first die you have rolled:" 
get diee  


-----------------------------------
rdrake
Tue Nov 20, 2007 9:24 pm

RE:how to continue a program after a loop
-----------------------------------
loop
    if GUI.ProcessEvent then
        break
    end if
end loop...I think.

-----------------------------------
Nick
Tue Nov 20, 2007 10:10 pm

RE:how to continue a program after a loop
-----------------------------------
looK up return

-----------------------------------
Tony
Wed Nov 21, 2007 12:36 am

RE:how to continue a program after a loop
-----------------------------------
I think GUI.ProcessEvent return false unless GUI.Quit (or equivalent) is called. This is an arbitrary convention, to accommodate

loop
   exit when GUI.ProcessEvent
end loop 

structure.

rdrake's code is equivalent to the above, since exit when condition is the same as

if condition then
   exit
end if


So you could break out of the loop by setting the exit flag with GUI.Quit in your di2 procedure. Though keep in mind that as soon as you exit that loop, your GUI will stop working since nothing is monitoring it.

-----------------------------------
Nick
Wed Nov 21, 2007 1:07 am

RE:how to continue a program after a loop
-----------------------------------
another thing is
var exit:boolean:=false
proc something()
exit:=true
end something
gui button call something()
loop
exit when gui
exit when exit
end loop

so u got 2 exit commands

-----------------------------------
Mazer
Wed Nov 21, 2007 7:03 am

RE:how to continue a program after a loop
-----------------------------------
Why the fuck?

EDIT: Oh hey, I found a way to do it with 3 exit commands
var exit:boolean:=false
var quit:boolean:=false
proc something()
exit:=true
end something
proc orother()
quit:=true
end orother
gui button call something()
gui button call orother()
loop
exit when gui
exit when exit
exit when quit
end loop

Gotta keep your options open in the early stages, right?
