Announcement

Collapse
No announcement yet.

Array Sort

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

  • Array Sort

    I must be missing something. I can't seem to get ARRAY SORT to sort a simple array. Can someone show me what I am doing wrong?

    Code:
    FUNCTION PBMAIN () AS LONG
        
        DIM LIST(1-100) AS STRING
        
        LIST (1) = "<ZZMYPROG>"
        LIST (2) = "<MOUNTAIN>"
        LIST (3) = "<BLUEBERRY>"
        LIST (4) = "<APPLES>"
        LIST (5) = "<CHERRIES>"
        
        ARRAY SORT LIST (), DESCEND
        
        PRINT LIST (1)
        PRINT LIST (2)
        PRINT LIST (3)
        PRINT LIST (4)
        PRINT LIST (5)
        
        WAITKEY$
    
    END FUNCTION
    This program does not sort the array. Why? What's wrong?

  • #2
    try and change the dimension of the array to 10 and print all ten

    Comment


    • #3
      OR...
      Code:
      ARRAY SORT list(1) FOR 5, DESCEND
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Tryed both ways. Program compiles but does not show any results and then get Windows message "Program not responding".

        Note: Using Windows Vista.
        Last edited by Martin Francom; 9 Jan 2009, 12:31 PM. Reason: additional info

        Comment


        • #5
          Array Sort

          If you dimension the array as DIM LIST(1 TO 100) AS STRING it will compile and sort. Apparently compiler does not understand the dimension 1-100.
          Last edited by Keith Eckerman; 9 Jan 2009, 12:59 PM.

          Comment


          • #6
            ADD TWO LINES AND RUN THIS:
            Code:
            FUNCTION PBMAIN () AS LONG
                
                DIM LIST(1-100) AS STRING
                PRINT ERR         ' ADD ME 
                WAITKEY$         ' ME TOO
                
                LIST (1) = "<ZZMYPROG>"
                LIST (2) = "<MOUNTAIN>"
                LIST (3) = "<BLUEBERRY>"
                LIST (4) = "<APPLES>"
                LIST (5) = "<CHERRIES>"
                
                ARRAY SORT LIST (), DESCEND
                
                PRINT LIST (1)
                PRINT LIST (2)
                PRINT LIST (3)
                PRINT LIST (4)
                PRINT LIST (5)
                
                WAITKEY$
            
            END FUNCTION
            MCM
            (You didn't really want to "DIM LINE (0 TO minus ninety-nine), did you?)
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              As Martin wrote:
              DIM LIST(1-100) AS STRING
              PRINT LBOUND(LIST());","; UBOUND(LIST())

              The PBCC5.0 compiler indicates the lower bound to be 0, upper bound is -1.

              Comment


              • #8
                Originally posted by Keith Eckerman View Post
                If you dimension the array as DIM LIST(1 TO 100) AS STRING it will compile and sort. Apparently compiler does not understand the dimension 1-100.

                Thank you.... Sometimes I just can't see the tree because of the forest.

                Comment


                • #9
                  Note: 1-100 = -99

                  Comment


                  • #10
                    99 bottles of beer on the wall, 99 bottles of beer, you take one down, pass it around...

                    Sorry, it's Friday, couldn't resist!

                    CH

                    Comment


                    • #11
                      >Note: 1-100 = -99

                      Oh, I'm so sorry, Bob, that's not correct. However, we do have some nice parting gifts for you, including the exciting Home Version of the PowerTree Index Manager..

                      The correct answer is, "9", THE 'ERR' VALUE FOR WHICH THIS PROGRAM SHOULD HAVE TESTED.
                      Michael Mattias
                      Tal Systems (retired)
                      Port Washington WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment

                      Working...
                      X