Shop OBEX P1 Docs P2 Docs Learn Events
How to make an array, or range in Spin — Parallax Forums

How to make an array, or range in Spin

TonyATonyA Posts: 226
edited 2007-07-29 22:45 in Propeller 1
Hi,

How can I set up an array, or declare a·range for a variable?

I want to have my variable select values from an array, or stay within a certain range of numbers.

Thanks,
Tony

Comments

  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-07-29 22:38
    VAR

    long/word/byte fictitious_name[noparse][[/noparse]n] (where n = size of array in longs/words/bytes)

    You cannot havce a variable select values from an array or any other location. You CAN create a function that can get a value from an array of var's and assign a local variable that value for proccessing.

    PUB main | local_variable_name

    local_variable_name := fictitious_name[noparse][[/noparse]0] <-- access the first element in the array and assign the value to Local_variable_name

    { do some statement with local_variable_name }

    I think more strongly that you want to use the Lookup or Lookdown function, it's in the manual.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.
  • TonyATonyA Posts: 226
    edited 2007-07-29 22:45
    Thanks. I'll check out the lookup/lookdown

    Tony
Sign In or Register to comment.