Arrays and Constants


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2013
    Posts
    6

    Default Arrays and Constants

    Hi everyone,

    Is there a way to use a constant to define the size of your array? eg:

    DEV CON 60
    LED VAR BYTE[WS]

    It compiles, but throws up a syntax error (Haven't tested in the program yet)

    Thanks.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Arrays and Constants

    Hi,
    That IS the way to do it.
    But you can't name the constant DEV and then use WS in the array declaration.... You need to use a constant that actually have been declared.
    Code:
    WS CON 60
    LED VAR BYTE[WS]
    /Henrik.

  3. #3
    Join Date
    Mar 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Arrays and Constants

    Thanks, yep that was just a typo.

    I'll have a go now I'm back with the project.

  4. #4
    Join Date
    Mar 2013
    Posts
    6


    Did you find this post helpful? Yes | No

    Default Re: Arrays and Constants

    Simple problem in the end.

    WS CON 60
    LED VAR BYTE[WS]

    Has to be above anything that uses it. If you don't it will compile O.K. but you will see a syntax error afterwards, and will not work.

    Badger...

Similar Threads

  1. Port Variables act like Constants
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th March 2011, 17:29
  2. PORTC constants
    By Forkosh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th October 2007, 05:43
  3. constants
    By cmolson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 1st December 2005, 13:33
  4. Bug ? Error in calculating constants
    By BigWumpus in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th October 2005, 21:55
  5. storing arrays and reading arrays
    By Yue in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 5th March 2004, 22:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts