Announcement

Collapse
No announcement yet.

Upper bound of arrays in PB/Win 8.04

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

    Upper bound of arrays in PB/Win 8.04

    What is the upper bound for arrays in PB/Win 8.04, when dimensioned simply as follows:

    DIM a(20) AS LONG
    DIM s(20) AS STRING

    I thought that the indexes for these arrays would range from 0 to 19. However, I'm finding a range of 0 to 20 in the following example:

    Code:
     
    #COMPILE EXE
    #DIM ALL
     
    FUNCTION PBMAIN () AS LONG
        DIM a(20) AS LONG
        DIM s(20)  AS STRING
     
        OPEN "output_TestArray.txt" FOR OUTPUT AS #17
     
        PRINT #17, "ubound_a = "; UBOUND( a(1) )
        PRINT #17, "lbound_a = "; LBOUND( a(1) )
        PRINT #17, "ubound_s = "; UBOUND( s(1) )
        PRINT #17, "lbound_s = "; LBOUND( s(1) )
     
        CLOSE #17
     
    END FUNCTION
    Sincerely,
    John Harvill

    #2
    0 to 20.
    Total = 21 elements.

    Its all in the help file.

    You can use this:

    DIM s( 1 to 20) AS STRING

    or...

    DIM s(0 to 19) AS STRING

    Comment


      #3
      Thanks,

      You're absolutely right. There it is in clear black and white.



      Sincereley,
      John Harvill

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎