Shop OBEX P1 Docs P2 Docs Learn Events
Array variable access — Parallax Forums

Array variable access

Ray0665Ray0665 Posts: 231
edited 2011-08-04 09:56 in Propeller 1
if a sub module defines a constant as
Con
#0, one,two,three,four

I can access an array element using that definition like this
somevariable[submodule#two]

But if the constant is defined in the top module
Con
#0, one,two,three,four

how do I access the array element in a sub module
somevariable[????????]

Comments

  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-08-04 09:39
    I don't think you do. You could pass the constant value down to it in a method call.
  • Ray0665Ray0665 Posts: 231
    edited 2011-08-04 09:50
    I was afraid of that
    After posting I was thinking that perhaps I could put the constants in a separate module and then access in the standard way.
    but I really don't like that, as a personal prejudice.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-04 09:56
    I've done that (move constant definitions to a "definitions" object). It actually worked out very nicely. BoeBotBasic is built that way with BB_definitions referenced in most of the other objects used.
Sign In or Register to comment.