I have an Animated Sort app that animates how 12 different sorting algorithms sort an array of numbers where bars represent the numbers and move as the array elements are moved during the sorting process.
The original program did all of its drawing straight to the canvas graphics object. A couple years back this was modified to work with a picture object which is painted during the canvas paint event.
This all works great when compiled for 32 bit. When I compile it for 64 bit no animation takes place. The bars all sit as originally painted until the sort is completed and then the final result of the sorted bars appears. It has me thoroughly puzzled. I don't do near the programming that I used to but I figured that this conversion would simply be changing build architecture popup menu in the MacOS Build settings from 32bit to 64 bit and then do a build and all would now be running in 64 bit.
In any of the sorting methods whenever two elements of the array are going to be swapped the doSwap method of the window is called and the code for them method looks like the following:
doSwap(bar1 as Integer, bar2 as Integer) Dim temp as Integer #pragma BackgroundTasks False #pragma BoundsChecking False // Swapping values in the i and j cells of the barsToSort array temp = barsToSort(bar1) barsToSort(bar1) = barsToSort(bar2) barsToSort(bar2) = temp numberOfSwaps = numberOfSwaps + 1 // boost swap count for this sort if doAnimation then // bypass if no animation running drawOneBar(bar1) // redraw first bar drawOneBar(bar2) // redraw the second bar end if
The drawOneBar method has the following code.
drawOneBar(theBar as Integer) Dim inc, xPos, yPos, yPosFull as Integer #pragma BackgroundTasks False #pragma BoundsChecking False if doAnimation then // bypass if no animation running inc = barWidth + spaceBetweenBars // width of bar and spacing xPos = 3 + (theBar - 1) * inc // x pos for this bar yPos = Canvas1.height - 1 - maxBarHeight // y pos for max bar height yPosFull = yPos sortPic.Graphics.foreColor = bkgndColor // set to bg color sortPic.Graphics.fillRect xPos, yPos, barWidth, maxBarHeight // blank out any old bar with background color yPos = Canvas1.height - 1 - barsToSort(theBar) // y position for new bar height sortPic.Graphics.foreColor = barColor sortPic.Graphics.fillRect xPos, yPos, barWidth, barsToSort(theBar) // draw new bar canvas1.RefreshRect(xPos, yPosFull, barWidth, maxBarheight, False) end if
The above, exactly as shown, works beautiful in 32 bit. In 64 bit I have tried with, and without, the #pragma statements with no change in execution. No animation takes place. Also, if multiple sort algorithms are chosen, the original bars are not re-shown after each sort finishes like they are in 32 bit.
Any suggestions on what is needed to get his working in 64 bit will be most appreciated. I guess this is what I get for thinking the conversion would be a simple click and recompile.