Strange Variable Issue ...


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,681


    Did you find this post helpful? Yes | No

    Default Re: Strange Variable Issue ...

    from the manual
    A single Array Variable can be visualized as a list of values. The variable name is
    how you access the list, and a number –or index– is used to point to any single
    value within the list.
    The index value is enclosed in brackets and appended after the array variable's
    name.
    myarray[index] = 0
    The index can be a literal number, a variable, or an expression.
    For the following examples, an array named "stored" is used:
    stored VAR WORD[8] 'Create an array named "stored"
    with 8 elements.
    Note that the 8 elements in our array are numbered 0 through 7. There is no
    element-8. This is very important, because PBP doesn't place a limit at the end of
    the array. If you write "stored[8]", PBP won't generate an error and you will be
    accessing memory outside of the array. (The end of the array is stored[7] and there
    is no stored[8].) This could have disastrous results and be very difficult to debug.
    The elements of "stored" can be written individually:
    stored[0] = 1260
    stored[1] = 2500
    Or, you might want to write values with a loop. You could read PORTB once per
    second and save 8 readings:
    FOR index = 0 TO 7 'Loop 8 times
    stored[index] = PORTB 'Save value of PORTB
    PAUSE 1000 'Wait a second
    NEXT index 'Loop again


    this is not just a pbp issue most 8 bit micro languages have the same limitation on array bounds checking ie . none at all

  2. #2
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103


    Did you find this post helpful? Yes | No

    Default Re: Strange Variable Issue ...

    Thank you Richard , for the amazing explanations ... Good to know and keep such knowledges for the pic that is working on the background of my brain ..
    - Ipsa scientia potestas est -

Similar Threads

  1. IF-THEN issue
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th February 2014, 23:09
  2. Assigning a string variable to another string variable
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd June 2013, 18:55
  3. strange readings
    By cheezy1963 in forum General
    Replies: 6
    Last Post: - 29th November 2007, 01:46
  4. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 09:52
  5. One variable made up of another variable
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 1st September 2007, 01:18

Members who have read this thread : 0

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