Shop OBEX P1 Docs P2 Docs Learn Events
BS2e — Parallax Forums

BS2e

hmlittle59hmlittle59 Posts: 404
edited 2008-11-25 05:14 in BASIC Stamp
Hello,

I'm needing more info to read on programming in slots. I'm having several variables change when I go back to slot0(run0). After I Run1 a routine that displays info on the LCD Screen and sets the DS1302 chip, I Run0 with a flag set thats telling me this is not the first time. But when I get back to slot0 some variables have changed that are not in that slot per the LCD screen.

I have 2 printouts from the forum but need some more info....thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

hmlittle59

Comments

  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-23 20:58
    Every variable is in every Slot. The variables in the various Slots all occupy the same storage, and to keep from changing variables unintentionally, you must declare all your variables identically in every Slot, no matter which Slot they're actually used in.

    If you don't do this, you may end up with variable GEORGE in Slot 0 at the same displacement as variable BILL in Slot 1. They've got different names, but they are the same byte of storage, so if you change BILL in Slot 1, you also changed GEORGE without intending to.

    The solution is to have all your variables declared identically in every Slot. Identically means really identically. Same names, same sizes, and in the same order.

    I consider it a very unfortunate omission in the Stamp editor that there is no way to include in a source program the contents of a separate file. Most compilers and assemblers on other computers have such a facility, known variously as INCLUDE or COPY, and sometimes by other names. Whatever they call it, it lets you write all those variable-defining statements once, and include them in many programs. Such a facility, if the Stamp editor had it, would save a lot of heartburn. It wasn't really needed for the Stamp until they invented Slots with the BS2E -- but failing to add it to the Stamp editor at that time was a real blunder, in my not-at-all-humble opinion.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net

    Post Edited (Carl Hayes) : 11/23/2008 9:10:58 PM GMT
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-23 21:27
    OOOOOPPPPPs,


    thanks Carl,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-23 21:42
    Carl ,

    Is there any thing special that I'm suppose to do before displaying to the LCD screen? As I get to the first loop with text and variable displayed, the first time through the loop half of text is displayed w/variable but the second time through its ok. I did a work around by printing 15 blank spaces" " to the top line. This works but does not seem to be the best way? Any thoughts?


    Again thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • dandreaedandreae Posts: 1,375
    edited 2008-11-24 14:35
    Try adding a PAUSE 20 to the first line of code in your LCD routine.

    Dave

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Parallax Tech Support·
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-11-25 05:14
    Found it,

    When I copied over my variables and constants, I also copied these I/O directors and they are causing the conflict...Could someone please explain the conflict this was causing so I will full understand the problem this was causing from Bank1.

    OUTS = %0000000000000000 'All logic low
    DIRS = %0000000000000111 'I/O 0,1 and 2 are output, rest are input


    thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
Sign In or Register to comment.