Shop OBEX P1 Docs P2 Docs Learn Events
[resolved] con vs constant — Parallax Forums

[resolved] con vs constant

kuronekokuroneko Posts: 3,623
edited 2009-06-11 01:49 in Propeller 1
I have the need to export some constants from an object which are based on labels in a DAT section. While compile time evaluation with constant() works I'd rather have something inside a CON section (so I can access the values by obj#constant). The latter doesn't seem to work however. The only solution so far is updating the CON section after potential code changes which is prone to errors. Is there a better solution or is this it, no DAT based expression inside a CON section?

CON
  size = 8
  
PUB null
PUB getSize

  return constant(@table_end-@table)
  
DAT

table           long    -1
                long    -2
table_end

DAT

Post Edited (kuroneko) : 6/11/2009 1:51:56 AM GMT

Comments

  • BradCBradC Posts: 2,601
    edited 2009-06-11 01:37
    kuroneko said...
    I have the need to export some constants from an object which are based on labels in a DAT section. While compile time evaluation with constant() works I'd rather have something inside a CON section (so I can access the values by obj#constant). The latter doesn't seem to work however. The only solution so far is updating the CON section after potential code changes which is prone to errors. Is there a better solution or is this it, no DAT based expression inside a CON section?

    Nope. That is the best you can do. The CON section is parsed first, well before anything in the DAT section is parsed. There is no way to set a constant based on any calculated value outside of the CON block.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Eccles : How do I open the door?
    Bluebottle : You turn the knob on your side
    Eccles : I haven't got a knob on my side!
  • kuronekokuroneko Posts: 3,623
    edited 2009-06-11 01:49
    BradC said...
    Nope. That is the best you can do. The CON section is parsed first, well before anything in the DAT section is parsed. There is no way to set a constant based on any calculated value outside of the CON block.
    I was afraid someone is going to confirm that [noparse]:)[/noparse] Thanks.
Sign In or Register to comment.