maximum or minimum of an array
Archiver
Posts: 46,084
Is there a single PBASIC command that would find the maximum (or
minimum) of a set of values stored sequentially (either in the main
RAM, or preferably in the SPRAM or the EEPROM) of a BS2p?
If not,
would it be possible to add such a command to PBASIC vocabulary in
the future versions?
Thanks
Mohammed
minimum) of a set of values stored sequentially (either in the main
RAM, or preferably in the SPRAM or the EEPROM) of a BS2p?
If not,
would it be possible to add such a command to PBASIC vocabulary in
the future versions?
Thanks
Mohammed
Comments
in fact the entire BASIC Stamp RAM can be treated like an array without
even declaring it explicitly. For example.
colors VAR Byte
red VAR Colors
green VAR Byte
blue VAR Byte
Since red is overlayed onto the same physical address as colors, and
green and blue are the same types, they will live in memory in this
order:
colors/red, green, blue
This means you can work with Red, Green, and Blue as named variables, or
index through them like this:
FOR idx = 0 TO 2
colors(idx) = idx
NEXT
After this loop, red will be zero, green will be one, and blue will be
two.
Another thing to keep in mind is that RAM arrays can be bits, nibs,
bytes, or words. SPRAM is accessed as bytes and words -- these issue
complicate creating an internal fuction (that you could certainly code
in PBASIC). This is not to say that the next-generation Stamp won't
have such a feature.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: mohammedrasiq [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=gsSNIOVefYgTutgtEwDYI8PJk9B0XcRbMGRq6VfzXufNbeRswhKUsCYudTdonHK8eUtl0Po0byDLkdWM9CxLvSc]mohammedrasiq@y...[/url
Sent: Tuesday, September 02, 2003 5:17 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] maximum or minimum of an array
Is there a single PBASIC command that would find the maximum (or
minimum) of a set of values stored sequentially (either in the main
RAM, or preferably in the SPRAM or the EEPROM) of a BS2p?
If not,
would it be possible to add such a command to PBASIC vocabulary in
the future versions?
Thanks
Mohammed
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/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> No. The reason is that array boundaries are NOT enforced by the
Stamp;
> in fact the entire BASIC Stamp RAM can be treated like an array
without
> even declaring it explicitly. For example.
>
> colors VAR Byte
> red VAR Colors
> green VAR Byte
> blue VAR Byte
>
> Since red is overlayed onto the same physical address as colors, and
> green and blue are the same types, they will live in memory in this
> order:
>
> colors/red, green, blue
>
> This means you can work with Red, Green, and Blue as named
variables, or
> index through them like this:
>
> FOR idx = 0 TO 2
> colors(idx) = idx
> NEXT
>
> After this loop, red will be zero, green will be one, and blue will
be
> two.
>
> Another thing to keep in mind is that RAM arrays can be bits, nibs,
> bytes, or words. SPRAM is accessed as bytes and words -- these
issue
> complicate creating an internal fuction (that you could certainly
code
> in PBASIC). This is not to say that the next-generation Stamp won't
> have such a feature.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: mohammedrasiq [noparse][[/noparse]mailto:mohammedrasiq@y...]
> Sent: Tuesday, September 02, 2003 5:17 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] maximum or minimum of an array
>
>
> Is there a single PBASIC command that would find the maximum (or
> minimum) of a set of values stored sequentially (either in the main
> RAM, or preferably in the SPRAM or the EEPROM) of a BS2p?
> If not,
>
> would it be possible to add such a command to PBASIC vocabulary in
> the future versions?
> Thanks
> Mohammed
>
>
> 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/
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p...