Shop OBEX P1 Docs P2 Docs Learn Events
Arrays — Parallax Forums

Arrays

Kurt FinnieKurt Finnie Posts: 21
edited 2009-05-06 02:52 in Propeller 1
I've been working at understanding arrays and have run into several problems.

The first is that I don't know how to display my spin code, so I'm going to write it all out.


VAR
long MainStack[noparse][[/noparse]9]
byte idx

OBJ
tv="tv_text"

PUB Main
tv.start

wordfill(@sail,0,1000)

repeat idx from 0 to 255 step 10
sail[noparse][[/noparse]idx] := idx

repeat idx from 1 to 255
tv.dec(word[noparse][[/noparse]@sail][noparse][[/noparse]idx]
tv.str(string(", "))

DAT
sail word 0,0,0, (... to 1000)


When I execute the above, my display shows all of the array elements as expected.
When I change 255 to 256 (or any larger number), my display scrolls continuously.

Ultimately, I'd like to have a 10,000 element word array and be able to display any segment of it on screen.

Why is the display scrolling?

There's got to be a better way of defining the array, rather than typing 1000 0's separated by commas.
The array has to be in the DAT section, not in the VAR section.

Kurt

Comments

  • CassLanCassLan Posts: 586
    edited 2009-05-06 01:00
    Make idx a word instead of a byte if it will be a value > 255, this maybe overflowing into some area of the stack that the tv_text object is using. That has been my experience using tv_text if it scrolls.

    as far as the DAT question...I'm sure there is a better way to do that but I don't know it.

    Rick
  • mparkmpark Posts: 1,305
    edited 2009-05-06 01:14
    dat
    sail   word  0[noparse][[/noparse] 1000 ] ' a thousand zeros
    
    
  • CassLanCassLan Posts: 586
    edited 2009-05-06 01:33
    nice one! I'll have to remember that ; )
  • Kurt FinnieKurt Finnie Posts: 21
    edited 2009-05-06 02:52
    Thank you all. Everything works now.
Sign In or Register to comment.