Shop OBEX P1 Docs P2 Docs Learn Events
Loading up an Array from string in DAT section — Parallax Forums

Loading up an Array from string in DAT section

CassLanCassLan Posts: 586
edited 2008-06-17 19:47 in Propeller 1
Hi,

I'm assuming the DAT section in a spin program would be the place to keep a game level.

I have a simple map:

DAT···········
map1···· byte· "SSSSSSSSSSSSSSSSS·SSSS· SSSSSSSSSSSSSSΔ"

I'm actually using other chars but they wont display in this post..anyway.

I'd like to·have these read into an array:

·mapdata[noparse][[/noparse]mapindex]

So that I may draw the map on screen as well as navigate through.

Whats the best way to read these values into my array?

Thanks,

Rick

Comments

  • CassLanCassLan Posts: 586
    edited 2008-06-16 19:31
    Found the syntax
    Page 167 in prop manual

    Index := 0
    repeat
    · Temp := BYTE[noparse][[/noparse]@MyString][noparse][[/noparse]Index++] 'Read chars into Temp
    · <do something with Temp> 'Perform task with character
    while Temp > 0 'Loop until end found

    Rick
  • tpw_mantpw_man Posts: 276
    edited 2008-06-17 19:02
    You can also use bytemove. It is faster than that repeat loop, but unless temp just gets printed to the screen, bytemove will not work work.

    [noparse][[/noparse]code]
    bytemove(@myarray, @mydata, 200) 'move 200 bytes from the address of mydata and write it to the address at myarray.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1011, so be surprised!


    Advertisement sponsored by dfletch:
    Come and join us on the Propeller IRC channel for fast and easy help!
    Channel: #propeller
    Server: irc.freenode.net or freenode.net
    If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
    tongue.gif
  • CassLanCassLan Posts: 586
    edited 2008-06-17 19:47
    Thanks, Thats very helpfull.

    Once I'm at the point where I need to trim the code up I will def do that!!!!

    Atm its not sure how long the level is so when the level is loaded from the DAT section it reads until it hits an end char. However when things are complete I guess I will know how long each level will be and have that length bytemove'd as a whole chunk like that and not char by char.

    thanks again,

    Rick
Sign In or Register to comment.