Shop OBEX P1 Docs P2 Docs Learn Events
Cleaning up code — Parallax Forums

Cleaning up code

Brian CarpenterBrian Carpenter Posts: 728
edited 2005-08-30 13:48 in BASIC Stamp
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!!

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-30 01:05
    Hello,

    ·· 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
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-08-30 01:38
    that is just a peice. sofar the whole thing uses up over 57% and i am just getting started

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-08-30 01:57
    ·· Then now would be the time to start planning the code to be a little more efficient.· If you have a need to have a lot of stored pulse settings you can use a table.· Likewise, your text segments could easily be placed into DATA statements and a single SEROUT routine called repeatedly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-08-30 05:53
    could you please give an example of what you are proposing?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-08-30 13:48
    Well, this might help:

    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
Sign In or Register to comment.