Announcement

Collapse
No announcement yet.

Updates during an array sort ?

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

  • Updates during an array sort ?

    How can I find out the progress of a powerbasic array sort?
    I want to update a progress bar during an array sort.

    ------------------
    Warped by the rain, Driven by the snow...

    jimatluv2rescue.com

  • #2
    You can't to this with the built-in ARRAY SORT statement, sorry!

    The only way you can do it would be to implement your own sort routine that could provide feedback about the progress of the sort.

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      If I might ask... What are you sorting that takes long enough to need a progress bar?

      The longest sort I've done so far was 214,000 lines of text which took around 3 seconds.

      --Dave


      ------------------
      Home of the BASIC Gurus
      www.basicguru.com
      Home of the BASIC Gurus
      www.basicguru.com

      Comment


      • #4
        Yeah, I sort more than a hundred thousand words in.. no time at all.
        However, if the array is so big, you might consider splitting it
        up into "components". Let's say you have a hundred thousand words
        that starts with the letter "A", another hundred thousand that
        starts with "B", etc. (same can apply to numbers).

        First do a quick split into "A-", "B-", "C-", etc, arrays and
        then sort them one by one, while you show a progress that is
        based upon which array is done. Just an idea..


        ------------------

        Comment


        • #5
          No need to split up the arrays, just use the (startelement) FOR numelements option in array sort.
          With the array presorted in pieces, the last sort will be pretty fast.

          Kinda like....

          Code:
          SortBlock = 50    ' how many elements get sorted per ARRAY SORT
          NumSorts = NumElments\SortBlock    ' integer divide is close enough
          
          FOR I = 0 to NumSorts -1
            ARRAY SORT MyArray(NumSorts*Sortblock) FOR SortBlock
            UpdateProgressBar (I/NumSorts *100) * .8 ' figure the presorting gets about 80% of the sort done
          NEXT I
          ' with the array partially sorted, sort the whole thing
          ARRAY SORT MyArray()
          UpdateProgressBar (100)
          When the array is presorted in pieces, the sort of the whole thing goes faster. YOu may need to tinker with the "sortblock' number.

          Of course, the "percent done" figure will not necessarily be accurate to the pixel level, but the idea of the progress bar is to show the user that 'something' is happening, right?

          MCM


          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            It is a 17+ meg text file of arcserve backup logs. It takes about
            6 seconds. I just wanted to give the ever impatient client something
            to look at.

            ------------------
            Warped by the rain, Driven by the snow...

            jimatluv2rescue.com

            Comment


            • #7
              Jim,

              Rather then monitoring the time, just pop up a small dialog box
              and start an animated bitmap like a file folder flying from point
              A to point B, and once the array sort is done, stop the animation
              and kill the dialog box. Maybe even add a Cancel feature.

              Just my II Cents...

              Regards, Jules

              Comment


              • #8
                Originally posted by Jules Marchildon:
                Rather then monitoring the time, just pop up a small dialog box
                and start an animated bitmap ...
                Who/what will dispatch window-messages to the animation during ARRAY SORT ?
                Just a thought




                ------------------
                Fred
                mailto:[email protected][email protected]</A>
                http://www.oxenby.se

                Fred
                mailto:[email protected][email protected]</A>
                http://www.oxenby.se

                Comment


                • #9
                  Spawn the ARRAY SORT into a secondary thread and do the animation in the primary thread.

                  --Dave


                  ------------------
                  Home of the BASIC Gurus
                  www.basicguru.com
                  Home of the BASIC Gurus
                  www.basicguru.com

                  Comment

                  Working...
                  X