Variables
Archiver
Posts: 46,084
As a matter of previous programming habit I always pre-clear or pre-
set variables when I create them. As of late though a project is
requiring more code than I originally anticipated, and I thought I
might save some space by removing the lines that set each variable to
zero after declaration. What I need to know is, when a variable is
created, what is it's initial value? Is it a zero? Or what's in
that memory location at that time? The manual doesn't seem to
specify.
Thanks,
Chris Savage
set variables when I create them. As of late though a project is
requiring more code than I originally anticipated, and I thought I
might save some space by removing the lines that set each variable to
zero after declaration. What I need to know is, when a variable is
created, what is it's initial value? Is it a zero? Or what's in
that memory location at that time? The manual doesn't seem to
specify.
Thanks,
Chris Savage
Comments
>As a matter of previous programming habit I always pre-clear or pre-
>set variables when I create them. As of late though a project is
>requiring more code than I originally anticipated, and I thought I
>might save some space by removing the lines that set each variable to
>zero after declaration. What I need to know is, when a variable is
>created, what is it's initial value? Is it a zero? Or what's in
>that memory location at that time? The manual doesn't seem to
>specify.
>
>Thanks,
>Chris Savage
>
>Hi Chris -
All variable are cleared to zero before the start of your program.
The manual speaks about near the area where it describes the two
different types of Stamp Memory - RAM and EEPROM.
Regards,
Bruce Bates
>To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
>from the same email address that you subscribed. Text in the Subject and
>Body of the message will be ignored.
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> All variable are cleared to zero before the start of
> your program.
> The manual speaks about near the area where it
> describes the two
> different types of Stamp Memory - RAM and EEPROM.
Okay, I found what you're talking about...So I guess
it's safe to assume that this is also true during a
reset? The manual describes a power-on condition.
Well, I will save my program anyway, then remove the
lines and see what happenes...Thanks for your
response.
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
I/O pins inputs.
-- Jon Williams
-- Parallax
In a message dated 10/17/02 9:34:02 AM Central Daylight Time,
knight_designs@y... writes:
> As a matter of previous programming habit I always pre-clear or pre-
> set variables when I create them. As of late though a project is
> requiring more code than I originally anticipated, and I thought I
> might save some space by removing the lines that set each variable to
> zero after declaration. What I need to know is, when a variable is
> created, what is it's initial value? Is it a zero? Or what's in
> that memory location at that time? The manual doesn't seem to
> specify.
>
> Thanks,
> Chris Savage
>
[noparse][[/noparse]Non-text portions of this message have been removed]
> After reset, the BASIC Stamp initializes all
> variables to zero and makes all
> I/O pins inputs.
Thanks Jon, between you and Bruce Bates, I had removed
the extra bits of code...I hadn't realized that I had
declared at least 10 variables and set each one to
zero right afterward. Removing those lines should
free up a bit of space...The declarations are all in
my Init routine at the beginning...Thanks again guys.
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
variables midstream through your program. You can "alias" variables to do
multiple simultaneous assignments. Like this:
temps VAR Word
airTmp VAR temps.HighByte
h2oTmp VAR temps.LowByte
Now you can clear airTmp and h2oTmp with...
temps = 0
... because they occupy the same physical memory space as temps.
My programs rarely grow so large as to need this trick, but it is handy to
have.
-- Jon Williams
-- Parallax
In a message dated 10/17/02 11:08:08 AM Central Daylight Time,
knight_designs@y... writes:
> Thanks Jon, between you and Bruce Bates, I had removed
> the extra bits of code...I hadn't realized that I had
> declared at least 10 variables and set each one to
> zero right afterward. Removing those lines should
> free up a bit of space...The declarations are all in
>
[noparse][[/noparse]Non-text portions of this message have been removed]
> Here's another tip if you really start running short
> and you need to clear
> variables midstream through your program. You can
> "alias" variables to do
> multiple simultaneous assignments. Like this:
Clever...Being somewhat new to BS2 programming I
haven't gotten into the little tips & tricks as I did
on the Z80. The reason the program has gotten so big
is because it's being ported from a custom Z80
controller which was used in a Custom-Built Audio
Power Amplifier. There's alot of text messages to be
displayed on the LCD screen, not to mention quite a
few functions that I used. But it proves that if you
put your mind to it, the Stamp really can replace MUCH
more complicated systems. The Z80 Controller (Which I
designed back in 1991) had an 8255PIA, 32K EPROM, 32K
SRAM (Dallas Battery Backed), LCD Interface, and a
discrete I/O port used in other designs, which
consisted of a 74LS374 and a 74LS244 (C=64 keyboard
interface, basically).
Anyway, back to the subject, I have gotten all the
functions into the BS2 except the FAN controller code,
and that's where I got nervous about space. After
making a few changes, I have alot more space.
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
BS2 and has built-in functions for LCDs (character type), I2C and 1-Wire
components. It also has eight 2K banks and you can read across banks.
I created a program once that stored strings in one bank that were used by
another. This frees up a lot of code space in the main program bank.
-- Jon Williams
-- Parallax
In a message dated 10/17/02 11:25:19 AM Central Daylight Time,
knight_designs@y... writes:
> Clever...Being somewhat new to BS2 programming I
> haven't gotten into the little tips & tricks as I did
> on the Z80. The reason the program has gotten so big
> is because it's being ported from a custom Z80
> controller which was used in a Custom-Built Audio
> Power Amplifier. There's alot of text messages to be
> displayed on the LCD screen, not to mention quite a
> few functions that I used. But it proves that if you
> put your mind to it, the Stamp really can replace MUCH
> more complicated systems. The Z80 Controller (Which I
> designed back in 1991) had an 8255PIA, 32K EPROM, 32K
> SRAM (Dallas Battery Backed), LCD Interface, and a
> discrete I/O port used in other designs, which
> consisted of a 74LS374 and a 74LS244 (C=64 keyboard
> interface, basically).
>
> Anyway, back to the subject, I have gotten all the
> functions into the BS2 except the FAN controller code,
> and that's where I got nervous about space. After
> making a few changes, I have alot more space.
>
[noparse][[/noparse]Non-text portions of this message have been removed]
> If you get stuck, you may want to consider the BS2p
> -- it is faster than the
> BS2 and has built-in functions for LCDs (character
> type), I2C and 1-Wire
> components. It also has eight 2K banks and you can
> read across banks.
Are you kidding Jon! Just kidding...I recently got
your 2002 catalog and I've been driving her NUTS with
all the goodies I want to get. I was actually looking
at the BS2p40 for a few applications, but I am waiting
to see if you guys offer any kind of special pricing
in the near future, as the $99 price tag is still a
bit too steep for me. But I could really use the
extra I/O!
> I created a program once that stored strings in one
> bank that were used by
> another. This frees up a lot of code space in the
> main program bank.
I didn't know that, but I will keep it in mind for
future purchase considerations. Thanks!
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
of any flavor you want -- by just using two pins. I really like I2C and all
the cool parts that are available.
Just be sure to check our web site frequently. We like to offer "Weekend
Specials" from time-to-time that can save you big bucks. Not too long ago a
member of the Dallas Personal Robotics Group (I live in Dallas) told me that
he bought something from one of our weekend specials because the price was so
good -- even though he didn't really need it!
And ... we have a new, easier-to-use web site coming soon. Be sure to check
it out.
-- Jon Williams
-- Parallax
In a message dated 10/17/02 11:46:47 AM Central Daylight Time,
knight_designs@y... writes:
> Are you kidding Jon! Just kidding...I recently got
> your 2002 catalog and I've been driving her NUTS with
> all the goodies I want to get. I was actually looking
> at the BS2p40 for a few applications, but I am waiting
> to see if you guys offer any kind of special pricing
> in the near future, as the $99 price tag is still a
> bit too steep for me. But I could really use the
>
[noparse][[/noparse]Non-text portions of this message have been removed]
> Remember that with the BS2p's I2C commands, you can
> get lots of extra I/O --
> of any flavor you want -- by just using two pins. I
> really like I2C and all
> the cool parts that are available.
Haven't played with I2C yet, although I have seen
considerable discussion in this group about it
recently.
> Just be sure to check our web site frequently. We
> like to offer "Weekend
> Specials" from time-to-time that can save you big
> bucks. Not too long ago a
Regarding this, I have been to the Web Site quite a
bit lately, and have seen nothing like that...Where do
you post these "Specials?"
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
knight_designs@y... writes:
> Regarding this, I have been to the Web Site quite a
> bit lately, and have seen nothing like that...Where do
> you post these "Specials?"
>
When they happen, they are [noparse][[/noparse]blatantly] posted on the home page. I'm in the
California office this week ... perhaps I can entice the Marketing group
[noparse][[/noparse]which I'm a part of] to have a weekend special. No promises, though ...
I'll see what I can do.
-- Jon Williams
-- Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]
> In a message dated 10/17/02 12:07:42 PM Central
> Daylight Time,
> knight_designs@y... writes:
> When they happen, they are [noparse][[/noparse]blatantly] posted on the
> home page. I'm in the
> California office this week ... perhaps I can entice
> the Marketing group
> [noparse][[/noparse]which I'm a part of] to have a weekend special. No
> promises, though ...
> I'll see what I can do.
Perhaps one on the BS2p40? ;-) If so, I'll bite!
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
knight_designs@y... writes:
> Perhaps one on the BS2p40? ;-) If so, I'll bite!
Well ... I tried, but it's not looking good for this weekend. Stay tuned
though, because you never know what's going to happen.
[noparse][[/noparse]Non-text portions of this message have been removed]
> In a message dated 10/17/02 12:15:45 PM Central
> Daylight Time,
> knight_designs@y... writes:
>
> Well ... I tried, but it's not looking good for this
> weekend. Stay tuned
> though, because you never know what's going to
> happen.
My response is:
Char0 DATA $00,$0A,$0A,$00,$00,$0E,$11,$00
But thanks anyway! LOL
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
knight_designs@y... writes:
> My response is:
>
> Char0 DATA $00,$0A,$0A,$00,$00,$0E,$11,$00
>
> But thanks anyway!
I see you've also found my LCD Character Creator. Don't worry, I believe you
will have reason to change to this soon:
Char0 DATA $00,$0A,$0A,$00,$11,$0E,$06,$00
-- Jon Williams
-- Parallax
-- Jon Williams
-- Parallax
[noparse][[/noparse]Non-text portions of this message have been removed]
> In a message dated 10/17/02 12:26:49 PM Central
> Daylight Time,
> knight_designs@y... writes:
>
> I see you've also found my LCD Character Creator.
> Don't worry, I believe you
> will have reason to change to this soon:
> Char0 DATA $00,$0A,$0A,$00,$11,$0E,$06,$00
I hope we're keeping everyone who's bored at work
today amused...Okay Jon, will keep my eyes open.
=====
Chris Savage
Knight Designs
324 West Main Street
Montour Falls, NY 14865
(607) 535-6777
http://www.knightdesigns.com
__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
>
> I hope we're keeping everyone who's bored at work
> today amused...
Hehe... Thank God it's Friday... (NZ time...).