Shop OBEX P1 Docs P2 Docs Learn Events
array in DAT section? — Parallax Forums

array in DAT section?

EricREricR Posts: 35
edited 2009-02-15 02:01 in Propeller 1
Is there any way to declare an array in the DAT section for use in Spin?

So far, I do this:

DAT
A_DAT_Array············ long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

However, I want the size definable by a constant, not by typing all these zeros.

Any comments are appreciated.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Eric

Comments

  • Harrison.Harrison. Posts: 484
    edited 2009-02-02 02:43
    Of course you can. I use it all the time for singleton objects.

    CON
      SIZE = 32
    
    DAT
    myarray    long 0[noparse][[/noparse]SIZE]     ' fills the 'array' with 0's
    
    
  • EricREricR Posts: 35
    edited 2009-02-02 03:22
    tongue.gif·It works!· Thank you.· That was one syntax I did not try.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Eric
  • EricREricR Posts: 35
    edited 2009-02-15 02:01
    freaked.gif·I am greatly surprised to find that renaming a source file does not necessarily mean that you have two instances of a singleton object!

    It is necessary to change at least 1 bit of the code to have multiple instances of a singleton object.· Example, in two files:

    in "FullDuplexSerial128.spin" (similar to SerialMirror) I have
    · dummy········ long 0··· ' marker to make file instances recognizeable as different

    in "Fish128.spin" (almost identical to above) I have
    · dummy········ long 1··· ' marker to make file instances recognizeable as different

    This is enough to make the Propeller Tool create two instances of this singleton object.· I am using version 1.2.5 of the tool.

    My OBJ section in the program that needs two instances looks like this:
    · ConsoleSerialDriver : "FullDuplexSerial128"
    · DebugSerialDriver : "fish128"





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Eric
Sign In or Register to comment.