Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Making a reset button work proplerly
Author Message
Bobby321

Posted: Tue Jan 17, 2012 1:09 pm   Post subject: Making a reset button work proplerly

What is it you are trying to achieve?
Making a thermometer that changes temperature from Fahrenheit to Celsius and repeats.

What is the problem you are having?
The program repeats by clicking the orange button and most of the time it works but sometimes it takes many clicks to reset it. I need help to make it repeat with only 1 click every time.

Describe what you have tried to solve this problem
Try making a GUI button, but still no help.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

 Turing: procedure drawrectangle     %screen formatting     setscreen ("graphics:800;400")     %orange button     var number : int     var rangeX, rangeY, button : int     cls     drawfillbox (200, 50, 250, 100, 42)     %keyboard input     put "Enter your temperature in farenheit from -4 to 68"     get number     put "Your temperature in celcius is:", (5 / 9) * (number - 32);     put "Click on the orange box to repeat"     %Mouse input     loop         mousewhere (rangeX, rangeY, button)         if (rangeX >= 200 and rangeX <= 250) and (rangeY >= 50 and rangeY <= 100) and button = 1 then             drawrectangle         else         end if         %Red box         drawbox (20, 40, 70, 100, 12)         drawbox (20, 100, 70, 160, 12)         drawbox (20, 160, 70, 220, 12)         drawbox (20, 220, 70, 280, 12)         %Yellow box         drawbox (70, 40, 120, 100, 43)         %Blue box         drawbox (120, 40, 170, 100, 54)         drawbox (120, 100, 170, 160, 54)         drawbox (120, 160, 170, 220, 54)         drawbox (120, 220, 170, 280, 54)         Text.Locate (1, 5)                 for x : 50 .. 100                 if number = 41 then                 drawfillbox(20,40,70,0+x,12)         delay(10)         end if                   if number = 35 then             drawfillbox (120, 40, 170, 0 + x, 54)             delay (10)             end if         end for     end loop end drawrectangle drawrectangle

Please specify what version of Turing you are using
4.1.1

mirhagk

Posted: Tue Jan 17, 2012 1:16 pm   Post subject: RE:Making a reset button work proplerly

well what you need to do is restructure your program.remove the loop from inside the function, as well as the mouse detection code, and put it outside. That way it gets drawn once, and then constantly checks if you press the button, and if so it calls the function again.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 2 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: