Cleaning up code
Brian Carpenter
Posts: 728
attached is a piece of code that i am working on.· I am wondering if i were to use a Lookup Lookdown table for the PW variable, would that save on Memory space.· Also make just one Serout command that info would be filled by another lookup table.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
Comments
·· I was going to say that you pretty much answered that without having to open up the code.· Tables can often make things more compact, more easily upgradeable, and sometimes even just easier to follow.· Less SEROUT statements always saves good chunks of space.· But after looking at your code, there's really not that much there to start with.· I was expecting a full memory map after reading your post, but you're at less than 1/4.· You should be fine unless this is not the complete code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's Only A Stupid Question If You Have Not Googled It First!!
FOR ThrottleValue = 1 TO 4
ON ThrottleValue GOSUB ThrottleNull, ThrottleOff, ThrottleLow, ThrottleMedium, ThrottleHigh
NEXT
That's just an example. In practice, you'd replace the FOR...NEXT loop with a LOOKUP command
And your ranges are kind of wide, so the 'CASE' keyword looks like the easiest way to encode them.
Okay, I've reviewed the code again.· You can compress it quite a lot.
1.· Use the CASE construct
2.· Parameterize your output routine -- I've done this on the attached with 'SendIt'.· This uses two new BYTE registers to put parameters in before the call -- but by doing this, your 'ra...rd' values can become 'CON' values, instead of register values.
Post Edited (allanlane5) : 8/30/2005 1:59:51 PM GMT