help with buttons
Author |
Message |
kasi
|
Posted: Tue Nov 20, 2007 7:06 pm Post subject: help with buttons |
|
|
how do i make it so that when the user clicks on the button the procedure(die) appears while using the rand.int command
thanks for your help in advance
this is just part of my code
code: |
import GUI
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",die)
var answer:string
var die : array 1 .. 6 of procedure dice
die (1) := dice1
die (2) := dice2
die (3) := dice3
die (4) := dice4
die (5) := dice5
die (6) := dice6
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))
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
kasi
|
Posted: Tue Nov 20, 2007 8:07 pm Post subject: Re: help with buttons |
|
|
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
code: |
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
|
|
|
|
|
|
![](images/spacer.gif) |
|
|