Shop OBEX P1 Docs P2 Docs Learn Events
Counting Sheep — Parallax Forums

Counting Sheep

dbjdbj Posts: 75
edited 2006-12-18 08:13 in BASIC Stamp
Hey , Wow I realy can't see the forest for the trees!! Trying to write some· code to count days 1,2,3 """ect,. ·I dont Understand why this won't work ! its like it stops looping back to the do
I have a ds1302 on a BS24P·to keep time just trying to count up from 1 to 365,
I have tried getting the days of year julian but can't seem to figure it out, went ·to Tracy Allen's web page but cant make it work either , Just trying something simple. Thanks


········· ' {$STAMP BS2p}
········· ' {$PBASIC 2.5}

········ X······· VAR···· Word

········ Main:
········· DO
········ PAUSE 200
········ IF hrs = 24 THEN
······· GOSUB keep
········ ELSE
········· GOTO Main
·········· ENDIF
············ LOOP
·············· keep:
················ X = 1 + X
·

Comments

  • Kevin WoodKevin Wood Posts: 1,266
    edited 2006-12-17 18:55
    You'll get all kinds of strange problems when you don't use a RETURN statement for a GOSUB call. Try that first.
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-12-18 01:04
    And IF you've already got a "MAIN: ..... GOTO MAIN" loop, you probably should also put a "DO .... LOOP". Especially if you have a "GOTO MAIN" inside the DO...LOOP.

    But yes, that GOSUB Keep, where Keep: has no return anywhere is not good.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-12-18 08:13
    dbg -

    That program never made it through the PBASIC IDE without errors, for one thing. The variable "hrs" is neither defined, nor is it used any where. Try to write a program that at least passes through the PBASIC IDE without errors, and we can go from there.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
Sign In or Register to comment.