Computer Science Canada

Buttons for Dummies!

Author:  recneps [ Mon Feb 09, 2004 4:13 pm ]
Post subject:  Buttons for Dummies!

I saw someone make a post in AsianSensation's "Suggest a Tutorial" post and thought i'd clarify it for the people.

First off, lets see what the Turing Reference Says about buttons. :

Quote:
Syntax GUI.CreateButton (x, y, width : int, text : string,
actionProc : procedure x ()) : int
GUI.CreateButtonFull (x, y, width : int, text : string,
actionProc : procedure x (), height : int, shortcut : char, default : boolean) : int


Description Creates a button and returns the button's widget ID.
The button widget is used to implement a textual button. When you click on a button, the button's action procedure is called. If a button is given a short cut, then entering the keystroke will cause the action procedure to be called. It will not visibly cause the button to depress.



Two Buttons
The x and y parameters specify the lower-left corner of the button. The width parameter specifies the width of the button. If width is less than the size necessary to display the button, the button is automatically enlarged to fit the text. The text parameter specifies the text to appear in the button. The actionProc parameter is the name of a procedure that is called when the button is pressed.

For GUI.CreateButtonFull, the height parameter specifies the height of the button. If height is less than the size necessary to display the button, the button is automatically enlarged to fit the text. The shortcut parameter is the keystroke to be used as the button's shortcut. The default parameter is a boolean indicating whether the button should be the default button. If there is already a default button, and default is set to true, then this button becomes the new default button.


Since this is "Buttons for Dummies", forget the CreateButtonFull. Got that? Bye! So now, we have The syntax, the description, and the explanation of the syntax.

So let me clarify. this is how you use the GUI.CreateButton command.

First, tell Turing you're gonna be using GUI, place this line at the top of your program.

code:
import GUI


Next, create procedures containing all the work you want that button to do, like....

code:
procedure hello
put "Hello User, you have clicked Button #1!"
end hello

procedure hi
put "Hello User, you have clicked Button #2!!"
end hi


Next, declare the button names as variables.

code:
var button1 :int
var button2:int


and Turn those variables into buttons!

code:
var button1:int:=GUI.CreateButton
var button2:int:=GUI.CreateButton


And finally, fill in the parameters for them.

code:
var button1:int:=GUI.CreateButton(x,y,0,"Button Text",procedure)
var button2:int:=GUI.CreateButton(x,y,0,"Button Text",procedure)

Where x and y are the bottom left corner of the button, and "0 is the width of the button( note: The width will be incresed if the button text is larger than the width of the button specified) "ButtonText" is the text on the button's face, and procedure is the procedure you named above that you want the button to call when being pressed.

Finally, you need to have a little thing in there to keep the program going until a button is pressed, otherwise it would just draw the button, and then finish the program. so we add:

code:
loop
exit when GUI.ProcessEvent
end loop


And thats it! So now we put it all together......



code:
import GUI

setscreen("graphics:300;125")

procedure hello
locate(1,1)
put "Hello User, you have clicked Button #1!"
end hello

procedure hi
locate(1,1)
put "Hello User, you have clicked Button #2!!"
end hi

var button1:int:=GUI.CreateButton(25,25,0,"Button 1",hello)
var button2:int:=GUI.CreateButton(25,50,0,"button 2",hi)

loop
exit when GUI.ProcessEvent
end loop

Author:  Paul [ Mon Feb 09, 2004 4:18 pm ]
Post subject: 

Hey! Are you implying Im a dummy? (j/k), thanks for the tutorial +bits. Oh yea, the import is lowercase, and the text writes over the buttons. What does GUI.ProcessEvent do exactly? Does it call anything with GUI in it? Thats why I don't know how to clear it. Sad

Author:  recneps [ Mon Feb 09, 2004 4:22 pm ]
Post subject: 

oops! forgot to make those changes! Its fixed now. And GUI . Process Event... if you break it down, it literally starts an infinite loop, UNTIL that GUI processes something (the button click) Get it?

Author:  Paul [ Mon Feb 09, 2004 4:27 pm ]
Post subject: 

Oh, so when you do this:
code:

var button1:int:=GUI.CreateButton
var button2:int:=GUI.CreateButton

The buttons are automatically drawn?

Author:  Delta [ Mon Feb 09, 2004 6:27 pm ]
Post subject: 

Heck no!
Writing the :
var button1:int:=GUI.CreateButton
var button2:int:=GUI.CreateButton

does absolutely nothing, besides giving you an error of course... I'm not sure why he would put that in there Confused sure its for dummies but still it gets ppl confused Confused

And ya without the GUI.ProcessEvent your GUI commands won't work... GUI.ProcessEvent processes and event such as keyboard or mouse events
(clicks, key strokes) if one of these events call a widget(your button/textfield/gui stuff) then it works...

Author:  AsianSensation [ Mon Feb 09, 2004 9:13 pm ]
Post subject: 

good attempts at tutorials

now if everyone begins to write a tutorial, we'll soon have enough to get all kinds of people at all different levels started.

here, have some bits.

+35 bits

Author:  shorthair [ Mon Feb 09, 2004 10:04 pm ]
Post subject: 

i think there is a thread about how to reset , the gui event , so that you can have multiple buttons in differnt parts of the program , but in hte turing 5 documentation there is a F9 about a command that resets it automatically , its a good update , if i had turing handy id give it to you, but im sure someonne here knows what it is

Author:  recneps [ Tue Feb 10, 2004 3:56 pm ]
Post subject: 

Well, i wrote it in pieces, set by step of what you have to do, so that was the first part

code:
var button1:int:=GUI.CreateButton
var button2:int:=GUI.CreateButton


and then i went on to tell you you needed to add things to it, like:

code:
var button1:int:=GUI.CreateButton(x,y,width,"text",proc)
var button2:int:=GUI.CreateButton(x2,y2,width2,"text2",proc2)


Understand now? the button will be drawn after you add in the parameters, x and y positions of the bottom left corner, height(automatically expands to fit the text if needed), the text on the button face, and the procedure the button calls when clicked.

P.S. Thanks for bits! Very Happy I'm thinking of more tutorials that people really need Smile

Author:  the_short1 [ Tue Feb 10, 2004 7:26 pm ]
Post subject: 

VERY COOL!!!! i was just thinking on asking Templest for help on this ssince hes the Aclaimed master GUI!

i want to fix my unit converter with each button and have a pop up area show the buttons FULL NAME!!!!

Id give you bits... but i saving up for a email now...only 1900 to go... (i have lots in my title)

Author:  the_short1 [ Tue Feb 10, 2004 8:26 pm ]
Post subject: 

btw is there a specific command for making a rounded button (oval) for my unit converter words.... the normal ones are too big....even with just letter a in button and width of 0

or should i just make a Menu for the Base and new unit of measure? Thanks,.....(I AM GUI NOOB)

Author:  recneps [ Tue Feb 10, 2004 8:41 pm ]
Post subject: 

I dont believe there is a command for round buttons, if there is, then I dont know Very Happy

but you could make your own buttons , they just wouldnt look as nice Smile
like
code:

drawoval(100,100,10,10,7)
buttonwait("down",x,y,button,updown)%Or something like that. :p
if x>90 and x<110 and y>90 and y<110 then
put "You clicked the oval. yay! Call a procedure here."
end if

Author:  Andy [ Tue Feb 10, 2004 9:54 pm ]
Post subject: 

code:

setscreen ("graphics:120;120,nobuttonbar,position:center;center")
var mx, my, mb : int
var r := 60
loop
    mousewhere (mx, my, mb)
    if mb = 0 then
        drawfilloval (60, 60, r, r, blue)
    end if
    if mb = 1 and mx ** 2 + mb ** 2 <= r ** 2 then
        drawfilloval (60, 60, r, r, red)
    end if
end loop

circle button

Author:  Paul [ Tue Feb 10, 2004 9:57 pm ]
Post subject: 

Thanx dodge, I've always wondered how to do a circle button, but there isn't a command for a GUI round or circle button is there?

Author:  Andy [ Tue Feb 10, 2004 10:17 pm ]
Post subject: 

not that i noe of...

Author:  SuperGenius [ Tue Mar 16, 2004 9:46 pm ]
Post subject: 

Thank you for this tutorial, because at the rate my comp sci class moves, we might get to processes and procedures by June.

I ran the code from the first post( You pressed button 1 / You pressed button 2) and when I closed the window another window opened called
Quote:
WidgetModule.tu
What is this window for?

Author:  AsianSensation [ Tue Mar 16, 2004 11:37 pm ]
Post subject: 

the WidgetModule is the file turing includes which gives you the access to the GUI modules/functions, etc. That's why you have to do import GUI at the beginning. It's kinda like a header file. So basicly, that means you can customize things to suit your taste and use a customized WidgetModule so things worklout nicer, or simply just look nicer. I know someone who personally drew out her own GUI buttons, and if she included that in the widget module and gave it to other people, others will be able to use the buttons she drew.

Author:  the_short1 [ Tue Mar 16, 2004 11:54 pm ]
Post subject: 

GUI. CreateRadioButton <<<makes a round button for forms...

and here is 10 BITs spencer

Author:  recneps [ Thu Mar 18, 2004 9:05 pm ]
Post subject: 

Thats cool. I didnt know that. and thanks ;D (By the way, where did you get so many bits??lol)

Author:  Paul [ Thu Mar 18, 2004 9:38 pm ]
Post subject: 

He was storing them in the items.

Author:  Thuged_Out_G [ Fri Mar 19, 2004 2:19 am ]
Post subject: 

although its called CreateRadioButton,its not really a button. more a rounded check box. except, with a radiobutton, once you click it, the only way i know of to unclick it, is to click another one(going by radiobuttons on webpages)...it would still work well as a button, but its not quite a button...just to clarify

Author:  recneps [ Fri Mar 19, 2004 11:27 am ]
Post subject: 

Interesting. So theres no need to edit my tutorial to explain round buttons? Wink

Author:  the_short1 [ Fri Mar 26, 2004 7:19 pm ]
Post subject: 

yes i was storing.... but meh... i like seing that LARGE number... also .i bough 'black' title effect so nonon would realy see the large numnber.... i saving up for 1500 so i can buy something....

second note...

instead of:

loop
exit when GUI.ProcessEvent
end loop

which sucks cuz it that happens and u havn;t pressed a button yet it will freeze ur program

i find this works TEN times better...

in your active game loop add this:

if GUI.ProcessEvent then
end if

and that works the same as the loop but, does not hang the program if you havn;t clicked on a button yet...

second alternative...

process guibuttonevent
loop
if GUI.ProcessEvent then
end if
end loop
end guibuttoneven

fork guibuttonevent

now it will always try to find a GUI button event and will happen more acurately... (you click on it and it will work in nano second isntead of maybe being delayed)

either way... MUCH better in my opinion.... is this method better in others eyes too??? or is it just me.....


stupid turing references sometimes...
very good for the older basic stuff..... but i think Holtsoft is not putting as much effort into the turing reference as the versions increase (with more functions)... like look at the newer functions... theres a whole lot less documentation and a lot more flaky....but i love the new version how they have more examples tho (and have buttons in help to auto run those)

Author:  Hotaru [ Thu May 20, 2004 7:29 pm ]
Post subject: 

~this tutorial is crap~even the one found on the newer version of turing is way more helpful than this~
~but thanks for this helpful tutorial though~

Author:  AsianSensation [ Thu May 20, 2004 9:52 pm ]
Post subject: 

Hotaru wrote:
~this tutorial is crap~even the one found on the newer version of turing is way more helpful than this~
~but thanks for this helpful tutorial though~


are you stupid? Did God give you 6 as your Intelligence score when he was rolling for your abilities?

Did you just wanted bits? If it's like that, here is some bits.

+ negtive 100 bits

there, you'll be owning some bits.

Author:  the_short1 [ Thu May 20, 2004 9:59 pm ]
Post subject: 

i was just goign to post a negative response to that...


but i dont have the mod powers to enforce...

Author:  DaVe g [ Sun Sep 19, 2004 11:08 am ]
Post subject: 

Thanks for the tutorial, I tried to make a ball chooser using buttons for my game, and then it chose colour, and just sat there and never went to the game =(

Author:  Malazan [ Tue May 10, 2005 9:49 pm ]
Post subject: 

Thanks so much for the tutorial. It's been a super help for me and my project Very Happy

Author:  adams [ Tue May 24, 2005 11:17 am ]
Post subject:  disposing buttons

I know you guys are creating buttons but how do you dispose them. I'm making a program with lots of buttons and 'forward proc' and "body proc' stuff like that etc... heres my program can you help with putting in GUi.Dispose or GUI.Disable or GUI.Hide.

code:
import GUI in "%oot/support/lib/GUI"
setscreen ("graphics:vga")
setscreen ("nocursor")
var pic : int := Pic.FileNew ("soccer_stadium.jpg")
var font1 : int := Font.New ("Arial:50:bold")
var font2 : int := Font.New ("Arial:50:bold")
var font3 : int := Font.New ("Arial:16:bold")
var becknum, beckham : int
becknum := 1
forward proc b1
forward proc b2
forward proc b3
forward proc b4

forward proc right1
forward proc right2
forward proc right3
forward proc right4

forward proc wrong1
forward proc wrong2
forward proc wrong3
forward proc wrong4


%***************question 1**************
%below displays what will appear after a button is selected
body proc wrong1
    cls
    Font.Draw ("Wrong", 0, 50, font2, black)
    b2
end wrong1
body proc right1
    cls
    Font.Draw ("Right", 0, 50, font1, black)
    delay (1250)
    cls
    %omit comments below
    %loop
    %        delay (60)
    %        beckham := Pic.FileNew ("beckham" + intstr (becknum) + ".BMP")
    %        Pic.Draw (beckham, 175, 100, picCopy)
    %        becknum := becknum + 1
    %        exit when becknum = 210
    %    end loop
    b2
end right1

body proc b1
    delay (1250)
    cls
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("From which country did Soccer originate?", 0, 375, font3, white)
    %buttons below (location and what will be displayed on the button)
    var button1 : int := GUI.CreateButton (100, 100, 20, "France", wrong1)
    var button2 : int := GUI.CreateButton (100, 130, 20, "England", right1)
    var button3 : int := GUI.CreateButton (100, 160, 20, "Spain", wrong1)
    var button4 : int := GUI.CreateButton (100, 190, 20, "Brazil", wrong1)
    var button5 : int := GUI.CreateButton (100, 220, 20, "Italy", wrong1)
    var button6 : int := GUI.CreateButton (100, 250, 20, "Germany", wrong1)
end b1

%**********question 2**********
body proc wrong2
    cls
    Font.Draw ("Wrong", 0, 50, font1, black)
    b3
end wrong2
body proc right2
    cls
    Font.Draw ("Right", 0, 50, font1, black)
    b3
end right2

body proc b2
delay (1250)
    cls
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("When did the sport become recognized?", 0, 375, font3, white)
    %buttons below (location and what will be displayed on the button)
    var button7 : int := GUI.CreateButton (100, 100, 20, "1894", wrong2)
    var button8 : int := GUI.CreateButton (100, 130, 20, "1855", wrong2)
    var button9 : int := GUI.CreateButton (100, 160, 20, "1848", wrong2)
    var button10 : int := GUI.CreateButton (100, 190, 20, "1877", wrong2)
    var button11 : int := GUI.CreateButton (100, 220, 20, "1863", right2)
    var button12 : int := GUI.CreateButton (100, 250, 20, "1886", wrong2)
end b2

%**********question 3**********
body proc right3
    cls
    Font.Draw ("Right", 0, 50, font1, black)
end right3
body proc wrong3
    cls
    Font.Draw ("Wrong", 0, 50, font1, black)
end wrong3

body proc b3
    delay (1250)
    cls
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("What country and City does FIFA originate?", 0, 375, font3, white)
    %buttons below (location and what will be displayed on the button)
    var button13 : int := GUI.CreateButton (100, 100, 20, "Paris, France", right3)
    var button14 : int := GUI.CreateButton (100, 130, 20, "London, England", wrong3)
    var button15 : int := GUI.CreateButton (100, 160, 20, "Toronto, Canada", wrong3)
    var button16 : int := GUI.CreateButton (100, 190, 20, "Budapest, Hungary", wrong3)
    var button17 : int := GUI.CreateButton (100, 220, 20, "New York, United States", wrong3)
    var button18 : int := GUI.CreateButton (100, 250, 20, "Berlin, Germany", wrong3)
end b3

%*********question 4**********
body proc right4
    cls
    Font.Draw ("Right", 0, 50, font1, black)
end right4
body proc wrong4
    cls
    Font.Draw ("Wrong", 0, 50, font1, black)
end wrong4

body proc b4
    delay (1250)
    cls
    Pic.Draw (pic, 0, 0, picMerge)
    Font.Draw ("Where did the first Olympic Soccer Tournament take place?", 0, 375, font3, white)
    %buttons below (location and what will be displayed on the button)
    var button19 : int := GUI.CreateButton (100, 100, 20, "Poland", wrong4)
    var button20 : int := GUI.CreateButton (100, 130, 20, "Scotland", wrong4)
    var button21 : int := GUI.CreateButton (100, 160, 20, "England", wrong4)
    var button22 : int := GUI.CreateButton (100, 190, 20, "Portugal", right4)
    var button23 : int := GUI.CreateButton (100, 220, 20, "Brazil", right4)
    var button24 : int := GUI.CreateButton (100, 250, 20, "Spain", wrong4)
end b4

b1
loop
    exit when GUI.ProcessEvent
end loop


Author:  TokenHerbz [ Thu Aug 25, 2005 8:11 pm ]
Post subject: 

ok well, i didn't understand anything besodes the 1st post...

And that dosn't explain the fillbutton.

Anyways...

i just wanted to say that your custom circle button dosn't work when u click the right side of it, only the left, or it appears that way on my comp anyways.

I will practice with GUI, but is it possible to Change the TEXT of the buton, when it is clicked?

Author:  jrblast [ Thu Dec 08, 2005 6:37 pm ]
Post subject: 

TokenHerbz wrote:
ok well, i didn't understand anything besodes the 1st post...

And that dosn't explain the fillbutton.

Anyways...

i just wanted to say that your custom circle button dosn't work when u click the right side of it, only the left, or it appears that way on my comp anyways.

I will practice with GUI, but is it possible to Change the TEXT of the buton, when it is clicked?


perhaps just create a new button over it? and stop making that one?

what if i want to execute other functions after the buttons? in my proggy the proc executes, but it doesnt continue after the loop :S

Author:  iker [ Thu Dec 08, 2005 10:49 pm ]
Post subject: 

is it just me, or is this topic considered old?

Author:  theguru [ Sun Jan 15, 2006 5:32 pm ]
Post subject: 

ok, this tutorial was extremely helpful but it left me with a lot of questions.
I've tried the different methods of processing the 'buttons' (sorry for my horrible terminology) using a loop, if statement and a process but none of them seem to help me with my problem is that I want to exit the loop after the button has been pressed (so I can continue with my program). For example I want to use a button as 'next' so when clicked it will continue on with the program. I know I can use getch or get or something like that but just to make it fancy I'd like to add some buttons.
Their squary and so cool Smile.

// I hope my questions actually makes sense to you guys Embarassed

Author:  Cervantes [ Sun Jan 15, 2006 5:35 pm ]
Post subject: 

You could use a Quit button, that calls GUI.Quit, then have the code for the rest of the program waiting after your exit when GUI.ProcessEvent loop

Alternatively, you could have your button call the code that runs the next part of your program.

Alternatively alternatively, you could make your own buttons, and not be so restricted in how you code.

Author:  Clayton [ Wed Jan 25, 2006 2:39 pm ]
Post subject: 

i would like to add a bit to this if you want your buttons to be disabled you would do this
code:

proc disableButton
GUI.Disable (buttonName)
end disableButton

this stops the button from working, also if you are drawing boxes and such on the screen and you dont want your buttons to disappear then use the GUI.Refresh command as such
code:

proc refreshButton
GUI.Refresh(buttonName)
end refreshButton

this basically redraws your buttons on top of the screen again in the middle of your program without actually creating it
hope this helps

Author:  flippy [ Wed Apr 26, 2006 12:52 pm ]
Post subject:  Didn't notice a reply to this, soooo...

shorthair wrote:
i think there is a thread about how to reset , the gui event , so that you can have multiple buttons in differnt parts of the program , but in hte turing 5 documentation there is a F9 about a command that resets it automatically , its a good update , if i had turing handy id give it to you, but im sure someonne here knows what it is


The only command I could find in the tutorial to reset the GUI event was GUI.ResetQuit... but I think that's the only one you need...

Author:  flippy [ Wed Apr 26, 2006 1:12 pm ]
Post subject:  Oh yeah... one more thing

BTW...

I was wondering if there was a way to exit a double layer fo loops (if that doesn'y make sense: call a button, press button, button calls a procedure that containes more buttons, press a second button, second procedure does it's stuff, exit to main program and keep going)

I would show you the code, but it is kinda long...

Author:  MysticVegeta [ Wed Apr 26, 2006 1:40 pm ]
Post subject: 

well to exit nested loops you need a boolean

Author:  Foundation [ Sat Sep 16, 2006 11:37 am ]
Post subject: 

Good tutorial, btw, I was just thinking, is there any way to change the appearances of the Turing buttons, they look too grey. Anyone post a tutorial on that?

Author:  Cervantes [ Sat Sep 16, 2006 2:01 pm ]
Post subject: 

The widgets are open-source. The code for them is written in Turing. You can find it in C:\Program Files\Turing\support\lib\guiclass, assuming your Turing directory is at C:\Program Files\Turing.

Alternatively, you could check out S-engine.

Author:  War_Caymore [ Fri Sep 22, 2006 7:50 am ]
Post subject: 

Before reading this, i was completely unaware on how to use Turing's GRI system. i'd like to thank the maker of this thread for teaching me how to use GUI, mostly becasue he pretty much made this for me (yes, i am a dummy...). I look foward for moer tutorials taht are for people jsut like me Very Happy

Author:  kompsai [ Tue Nov 07, 2006 3:41 pm ]
Post subject: 

props, great explanation...really clarifies how to make some basic buttons.

though the step-by-step thing was a good idea, i think it should probably be changed because it is a bit confusing...believe it or not, it's most understandable starting from the bottom and working your way up to the top.

Author:  Macbuchu [ Thu Dec 21, 2006 7:17 pm ]
Post subject:  Need to continue on program after procedure

is it possible to put a process instead of a procedure at the end of the button somehow??? cuz i need to continue on my program after my procedure.

Author:  Macbuchu [ Thu Dec 21, 2006 7:19 pm ]
Post subject:  Need to continue on program after procedure

is it possible to put a process instead of a procedure at the end of the button somehow??? cuz i need to continue on my program after my procedure. look at code ..... ===>

Author:  CodeMonkey2000 [ Thu Dec 21, 2006 8:26 pm ]
Post subject: 

dude do u go to cameron?and for something like this dont use process except for music.

Author:  Macbuchu [ Mon Jan 01, 2007 8:21 pm ]
Post subject: 

yah i do and i finally got past my prblem

Author:  elmocookies [ Tue Jan 02, 2007 8:50 pm ]
Post subject: 

Does anyone know if there is tutorial on GUI.CreateRadioButtons or is this the only tutorial for anything involving GUI?

Author:  beginnerprogrammer [ Sat May 26, 2007 3:19 pm ]
Post subject:  RE:Buttons for Dummies!

i just started programmering and turing i don't know what this error means it is. The error is it is unable to pen file GUI. Why isn't it working i followed all the instructions

Author:  Agner [ Tue Feb 24, 2009 9:24 pm ]
Post subject: 

Clayton @ Wed Jan 25, 2006 11:39 am wrote:
i would like to add a bit to this if you want your buttons to be disabled you would do this
code:

proc disableButton
GUI.Disable (buttonName)
end disableButton

this stops the button from working, also if you are drawing boxes and such on the screen and you dont want your buttons to disappear then use the GUI.Refresh command as such
code:

proc refreshButton
GUI.Refresh(buttonName)
end refreshButton

this basically redraws your buttons on top of the screen again in the middle of your program without actually creating it
hope this helps


So if I want to have multiple buttons throughout my program (and not have them reappearing in sections I don't want them in), I would just use these commands or is there more? Confused Question Confused

Btw nice tutorial on GUI, helped me a lot with making buttons, I just need to figure out how to remove them when I don't need em Very Happy

Author:  flyforfame [ Sat Mar 28, 2009 8:50 pm ]
Post subject:  Re: Buttons for Dummies!

hi can u tell me how to make the program go to a next question?
for example i put What is Ice cream made out of and there is 2 buttons i can click
how can i make it so that if i click any of the 2 buttons i go the to the next question for example the next question is What is Fries made out of
so like this
What is ice cream made out of?
button 1
button 2
so if someone clicks one of the buttons it clears the page and goes to
What is Fries Made out of?
button 1
button 2
etc etc
and please reply as soon as possible i need to use this for my project

Author:  qmanjr5 [ Mon Jan 11, 2010 11:19 am ]
Post subject:  RE:Buttons for Dummies!

Can the loop go ANYWHERE in the code?

Author:  qmanjr5 [ Mon Jan 11, 2010 11:24 am ]
Post subject:  RE:Buttons for Dummies!

Also, how would I make it so it displays the button at a certain point in the code?

Turing:

import GUI
var button1 : int := GUI.CreateButton (25, 25, 0, "Button 1", test1)

procedure test1
    put button1
end test1


put button1


Doesn't work, even if I put "var button1..." after "procedure test1...."

How would i make this work?

Author:  xBalmungx [ Wed Jan 13, 2010 6:05 pm ]
Post subject:  Re: Buttons for Dummies!

Omg, this helped alot, thank you sooo much Very Happy

Author:  blizzard4800 [ Fri Jan 15, 2010 6:46 pm ]
Post subject:  RE:Buttons for Dummies!

Thank you soooooooo much

Author:  blizzard4800 [ Fri Jan 15, 2010 7:45 pm ]
Post subject:  RE:Buttons for Dummies!

but it doesnt work when you change the colour of the boutton

Author:  qmanjr5 [ Mon Jan 18, 2010 9:11 am ]
Post subject:  RE:Buttons for Dummies!

how WOULD you change the color of the button?

Author:  TheGuardian001 [ Mon Jan 18, 2010 9:33 am ]
Post subject:  Re: RE:Buttons for Dummies!

qmanjr5 @ Mon Jan 18, 2010 9:11 am wrote:
how WOULD you change the color of the button?

with the gui_setcolor command, which appears to work fine for me.

Author:  A2theBEAST [ Wed May 19, 2010 7:27 pm ]
Post subject:  RE:Buttons for Dummies!

Great tuti, I understand the button GUI commands pretty well now, Is there a way besides GUI.setsize to change the height of the button?

Author:  jacobjacobb [ Thu Jun 10, 2010 7:53 pm ]
Post subject:  Re: Buttons for Dummies!

can someone check my code and tell me whats wrong. Its suppose to be a rock, paper, scissors game.



import GUI

setscreen("graphics:400;450")

var choice : char
var bet : int
var winning : int
var money : int
var answer : char

put "What difficulty do you want to play? Hard(H), Medium(M), or Easy(E)? " ..

procedure easy
locate(5,1)
put "You chose Easy!"
answer := "e"
end easy

procedure medium
locate(5,1)
put "You chose Medium!"
answer := "m"
end medium

procedure hard
locate(5,1)
put "You chose Hard!"
answer := "h"
end hard

var button1:int:=GUI.CreateButton(50,50,0,"Easy",easy)
var button2:int:=GUI.CreateButton(150,50,0,"Medium",medium)
var button3:int:=GUI.CreateButton(250,50,0,"Hard",hard)

loop
exit when GUI.ProcessEvent
end loop

if answer = "E" or answer = "e" or answer = "easy" or answer = "Easy" or answer = "EASY" then
money := 1000
elsif answer = "M" or answer = "m" or answer = "medium" or answer = "Medium" or answer = "MEDIUM" then
money := 750
elsif answer = "H" or answer = "h" or answer = "hard" or answer = "Hard" or answer = "HARD" then
money := 500
end if

loop
var random := Rand. Int (1, 3)
put "You have " ..
put money ..
put " dollars left to bet."
put "How much money do you want to bet? " ..
get bet
if bet > money then
put "You have been caught trying to cheat!"
put "Remember kids the T-rex ate the Unicorn."
put "Listen carefully."
for count : 1..3
sound (440, 500)
sound (400, 500)
sound (500, 500)

sound (360, 500)
end for
sound (440, 600)
quit
end if
put " "
put "Rock(r), Paper(p) or Scissors(s)?(Push e to exit the game) " ..
get choice
if choice = "r" and random = 1 then
put "Computer chose Rock. "
put "You chose Rock."
put "Its a tie."
elsif choice = "p" and random = 2 then
put "Computer chose Paper. "
put "You chose Paper."
put "Its a tie."
elsif choice = "s" and random = 3 then
put "Computer chose Scissors. "
put "You chose Scissors."
put "Its a tie."
elsif choice = "r" and random = 3 then
put "Computer chose Scissors. "
put "You chose Rock."
put "You won."
money := bet + money
elsif choice = "p" and random = 1 then
put "Computer chose Rock. "
put "You chose Paper."
put "You won."
money := bet + money
elsif choice = "s" and random = 2 then
put "Computer chose Paper. "
put "You chose Scissors."
put "You won."
money := bet + money
elsif choice = "s" and random = 1 then
put "Computer chose Rock. "
put "You chose Scissors."
put "You lose."
money := money - bet
elsif choice = "p" and random = 3 then
put "Computer chose Scissors. "
put "You chose Paper."
put "You lose."
money := money - bet
elsif choice = "r" and random = 2 then
put "Computer chose Paper. "
put "You chose Rock."
put "You lose."
money := money - bet
end if
put " "
if money < 1 then
put "You lose."
put "Remember kids the T-rex ate the Unicorn."
put "Listen carefully."
for count : 1..3
sound (440, 500)
sound (400, 500)
sound (500, 500)

sound (360, 500)
end for
sound (440, 600)
quit
end if
if money > 4999 then
put "You win!"
put "Remember kids the T-rex ate the Unicorn."
put "Listen carefully."
for count : 1..3
sound (440, 500)
sound (400, 500)
sound (500, 500)

sound (360, 500)
end for
sound (440, 600)
quit
end if
if choice = "e" or choice = "E" or choice = "exit" or choice = "Exit" or choice = "EXIT" or choice = "quit" or choice = "Quit" or choice = "QUIT" then
put "You have quit."
put "Remember kids the T-rex ate the Unicorn."
put "Listen carefully."
for count : 1..3
sound (440, 500)
sound (400, 500)
sound (500, 500)

sound (360, 500)
end for
sound (440, 600)
quit
end if
end loop

Author:  USEC_OFFICER [ Thu Jun 10, 2010 8:26 pm ]
Post subject:  RE:Buttons for Dummies!

Um, why isn't this in a seperate topic?

Author:  Cezna [ Fri Jun 11, 2010 5:15 am ]
Post subject:  RE:Buttons for Dummies!

@ jacobjacobb
you will get much more attention for your program if you post it in a separate topic, which from the start of your post, should probably be in the Help section

Author:  hahd [ Mon Nov 08, 2010 10:33 pm ]
Post subject:  RE:Buttons for Dummies!

who u calling a dummy jkin thnkx for the help

Author:  Space!!! [ Sun Jan 02, 2011 4:23 pm ]
Post subject:  RE:Buttons for Dummies!

Wondering how to move or drag a button?

Author:  Birdo [ Tue Jun 28, 2011 11:28 pm ]
Post subject:  RE:Buttons for Dummies!

wow so helpful

Author:  Gaddy [ Tue Dec 25, 2012 11:20 am ]
Post subject:  RE:Buttons for Dummies!

My teacher makes us use procedures how would i make a GUI button to work for that procedure and lead to another one

Author:  Shootforwhat [ Thu Mar 21, 2019 7:20 pm ]
Post subject:  Re: Buttons for Dummies!

what if I want to exit the loop with one of the two buttons but let the other button continue on with the loop.


: