Computer Science Canada GUI buttons help |
Author: | jwang [ Thu Dec 07, 2017 2:39 pm ] |
Post subject: | GUI buttons help |
I'm trying to change my main menu's 3 option buttons into. GUI buttons. Here's my program code %Declaration Section var guess:int var answer:int var choice:string var playchoice:string:="a" var exitchoice:string:="b" %Random Number procedure randNum randint(answer,10,30) end randNum %Program Title procedure title locate(1,25) put"The Guessing Game" put"" end title %Goodbye Screen procedure goodbye cls drawfillbox(0,0,maxx,maxy,yellow) colorback(yellow) title locate(15,1) colorback(yellow) put"Thanks for playing the guessing game!" put"" put"This program was written by: ".. put"Jerry Wang" end goodbye %Program pauseProgram procedure pauseProgram var reply:string(1) put"" put"Press any key to continue....".. getch(reply) end pauseProgram %Program Introduction procedure introduction cls title randNum put"This program will allow you to guess a number." put"You have three chances to get it right." pauseProgram end introduction %User Input procedure userInput cls title put"" put"Integers only please!" put"" put"Plase enter an integer between 10 and 30: ".. end userInput %Program error window proc errorwindow var errorwin:=Window.Open("position:250;250,graphics:450;250") Window.Show(errorwin) if choice not=playchoice and choice not=exitchoice then put"Sorry, you must enter a or b. Please try again." put"Press any key to continue ".. loop exit when hasch end loop elsif guess >30 or guess <0 then put"Sorry, your guess is not in the right range. Please try again." put"Press any key to continue".. loop exit when hasch end loop end if Window.Close(errorwin) end errorwindow %Program Main Menu procedure mainmenu cls title put"a. play game" put"b. exit" put"" put"enter a or b: ".. get choice if choice = playchoice then userInput end if end mainmenu %Output&Processing procedure display title locate(6,43) get guess if guess > answer then put"the number is too high" elsif guess < answer then put"the number is too low" else put"Right on! This is the correct answer" end if end display % procedure %Main Program introduction for decreasing x: 2..0 %For loop %If statements for main menu mainmenu if choice not=playchoice and choice not=exitchoice then loop errorwindow mainmenu exit when choice=exitchoice or choice=playchoice end loop end if exit when choice = exitchoice %If statements for display display if guess >30 or guess <0 then loop errorwindow display exit when guess<=30 and guess>=0 end loop end if put"You have ",x," tries left" delay(1500) exit when guess=answer end for %End for loop goodbye put"the correct answer is ",answer if guess=answer then locate(3,25) put"Congratulations,You got it!" end if %End program Please help. Thanks |
Author: | TokenHerbz [ Tue Dec 12, 2017 3:35 am ] |
Post subject: | RE:GUI buttons help |
this is what you are looking for, start here... http://compsci.ca/v3/viewtopic.php?t=3583 |
Author: | jwang [ Tue Dec 12, 2017 8:07 am ] |
Post subject: | RE:GUI buttons help |
Thanks! |
Author: | LolADuck [ Tue Dec 12, 2017 12:19 pm ] |
Post subject: | RE:GUI buttons help |
var button : int := GUI.CreateButton (x, y, 0, "buttonname", procedure) var button2 : int := GUI.CreateButton (x, y, 0, "buttonname", procedure) var button3 : int := GUI.CreateButton (x, y, 0, "buttonname", procedure) loop exit when GUI.ProcessEvent end loop and it will work. have each of the three buttons link to a procedure. |