Shop OBEX P1 Docs P2 Docs Learn Events
newbie: help with array! — Parallax Forums

newbie: help with array!

paradrapeparadrape Posts: 3
edited 2008-05-06 17:38 in BASIC Stamp
hi forum,

i'm trying to do something simple and i hope you can help.

I have a list of numbers of Air Quality data from Beijing that i'm trying to visualize using the BS2. I want to write some code that will look at a number in the list, see if it is between certain values, then do something based on the outcome.

my pseudoish code is here:

----

Air_Quality_Data· DATA 35, 47, 78, 102, 123, 153, 89, 190, 54, 34, 86, 75, 123

(here i need some code where each successive value in the list is set to a variable, call it "i", and the value of "i" is
evaluated by the code below, sending data to the board)

Activate:
· ELSEIF (i > 50) AND (i < 100) THEN
··· PULSOUT 2, 2000
· ELSEIF (i > 100) THEN
··· PULSOUT 2, 2000
··· PULSOUT 8, 2000
· ENDIF
RETURN

----

can you help me fill in the blanks and correct my code?

thanks. this is the first time i've done this and i'm a bit stuck even with the manual.

- paradrape

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-06 12:46
    Since you're using the DATA statement, I assume that this list is stored in EEPROM and is fixed when you compile your program. You would use the READ statement to get this data and the label "Air_Quality_Data" will be the starting point of the list. The chapter in the manual on the READ and DATA statements have some examples of this sort of thing.
  • AmaralAmaral Posts: 176
    edited 2008-05-06 13:31
    If you want to make this values to go to a variable , set :

    aux var nib

    i var byte(12) 'take a look here that I'm based on your example were all the values are under value 255 (witch fit into a byte) and you are checking 13 values
    j var byte 'just a place to work with the numbers

    FOR aux=0 TO 12
    j = i(aux)
    GOSUB Activate
    next

    'keep up with the tasks



    Hope to help


    Amaral
  • paradrapeparadrape Posts: 3
    edited 2008-05-06 17:19
    thanks for your help guys. i will post as soon as i get something working (or not working)
  • Matthew BurmeisterMatthew Burmeister Posts: 49
    edited 2008-05-06 17:38
    Lets hope it works!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the blue smoke comes out of a Basic Stamp... You know that you did something wrong... -- Matthew
Sign In or Register to comment.