Announcement

Collapse
No announcement yet.

Var array with CONST

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • John Kevin
    commented on 's reply
    No problem. I am glad it helped

  • 4DSysFan
    replied
    Hi Kevin,
    It was in the same function (main), but before the usage. Placing it outside Main worked. I am used to GCC, which does all compiler substitutions first...
    Thanks!

    Leave a comment:


  • John Kevin
    replied
    Hello,
    As stated on the 4DGL Reference Manual, section 4.

    A variable or array can only be initialized with a constant value.
    The compiler does not know the value of NUMBTNS until runtime.

    Did you place your constant declaration inside the function?
    Constants need to be defined globally.

    I hope this helps.

    Best Regards,
    Kevin
    Last edited by John Kevin; 27th March 2019, 05:31 PM.

    Leave a comment:


  • 4DSysFan
    started a topic Var array with CONST

    Var array with CONST

    Any idea why the following throws an error:
    Code:
    #CONST
        NUMBTNS 24
        BTN_UP 0
        BTN_DOWN 1
        BTN_ONUP 2
        BTN_ONDOWN 3
    #END
        var i, x, y, state, n, Wbs1, Wbs3to5 ;
        var btn_State[NUMBTNS];
    Throws the following error:
    Error: Needs constant value expression for array size

    Thanks
Working...
X