Shop OBEX P1 Docs P2 Docs Learn Events
BYTE VAR initialization — Parallax Forums

BYTE VAR initialization

ArchiverArchiver Posts: 46,084
edited 2004-03-23 16:08 in General Discussion
When a BYTE VAR is declared does it need to have a value of 0
assigned to it or are VAR's automatically initialized to 0.
Thanks
Jack

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-03-23 16:01
    In a message dated 3/23/2004 10:57:35 AM Eastern Standard Time,
    jlindsay24@y... writes:


    > When a BYTE VAR is declared does it need to have a value of 0
    > assigned to it or are VAR's automatically initialized to 0.
    > Thanks
    >

    All variables are 0 when you boot up. They retain their value as long as
    power is maintained on the chip.


    Sid Weaver
    W4EKQ
    Port Richey, FL


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2004-03-23 16:08
    When the BASIC Stamp resets (after power up for reset pin pulled-low
    then released), ALL variables are cleared to zero and all IO pins are
    made inputs. Initializing a variable to zero just consumes code space.
    The only acception to this suggestion is that you may need your program
    to return to a code-based initialization section that does indeed reset
    some variables to zero.

    -- Jon Williams
    -- Applications Engineer, Parallax
    -- Dallas Office


    Original Message
    From: Jack Lindsay [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=n-iqFWGbpgFmKguFSZWcyZJgYW5FmjKO6xBdNmjUQppqS6XyPOccwbrhrWk0SyZzdhDyzytKoFuT2HOO6iw]jlindsay24@y...[/url
    Sent: Tuesday, March 23, 2004 8:37 AM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] BYTE VAR initialization


    When a BYTE VAR is declared does it need to have a value of 0
    assigned to it or are VAR's automatically initialized to 0. Thanks Jack
Sign In or Register to comment.