Making my program more "efficient"
Author |
Message |
justin_lim222
|
Posted: Fri Apr 29, 2011 2:55 pm Post subject: Making my program more "efficient" |
|
|
What is it you are trying to achieve?
According to my teacher, I need to make my code more 'efficient'. It is just a simple temperature converter
What is the problem you are having?
I don't see any way I can make my program any more 'efficient', besides removing unnecessary spaces and comments. (I'm a beginner, as you can obviously tell)
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I've attached it guys.
Thanks so much guys. I really appraciate it, if you could help! (:
Description: |
|
Download |
Filename: |
Temperature Conversion.t |
Filesize: |
3.83 KB |
Downloaded: |
113 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
RandomLetters
|
Posted: Fri Apr 29, 2011 3:05 pm Post subject: RE:Making my program more "efficient" |
|
|
I don't see how it could get more efficient, but you should try to remove repetitive code, like all the
celsius := 0
farenheit := 0
winID2 := Window.Open ("graphics:640,400, position:middle,center")
Window.Hide (winID)
setscreen ("graphics:400,200")
GUI.SetBackgroundColour (53)
Text.ColourBack (53)
which is in each proc and does not need to be.
|
|
|
|
|
|
justin_lim222
|
Posted: Fri Apr 29, 2011 3:10 pm Post subject: Re: Making my program more "efficient" |
|
|
Ok, but how would I do that? Because I need a new screen to pop up when the button is clicked ~ Which is why I made it a proc.
I've just started with turing, so please bear with me!
|
|
|
|
|
|
DemonWasp
|
Posted: Fri Apr 29, 2011 3:18 pm Post subject: RE:Making my program more "efficient" |
|
|
There's nothing particularly inefficient about this, but from a user-interface perspective there are a lot of designs that make more sense. For example, you could have:
code: |
________ C [Convert to F ] = ________ F
________ F [Convert to C ] = ________ C
[Quit]
|
This design leaves everything on just one screen (instead of 4) and lets the user keep the converted value around as long as they want.
In a more competent language than Turing, I would suggest a simpler design: two text boxes, and whenever the user edits one you automatically change the other to match. Then there aren't any buttons, and there's only two inputs. However, it turns out that Turing's GUI module doesn't listen for most of these events, and is therefore incapable of that design.
|
|
|
|
|
|
mirhagk
|
Posted: Fri Apr 29, 2011 5:52 pm Post subject: RE:Making my program more "efficient" |
|
|
You can still create text boxes, the user just has to hit enter in order to update the other box.
|
|
|
|
|
|
DemonWasp
|
Posted: Fri Apr 29, 2011 10:19 pm Post subject: RE:Making my program more "efficient" |
|
|
You can create text fields, but there's still no event for "on changed by user", regardless of whether they hit enter or not.
|
|
|
|
|
|
|
|