Subject: Well then have a look at his code . . .a shift down arrow and delete an If…Then line, then…
Hi,
I think keeping other users informed about little bugs is one of the tasks for such a forum, right? This can sometimes save time.
Btw. Unfortunatly I havn’t got any email from this forum though I wanted to be informed. That’s why I answer so late. My apologies.
Here is a method where I first detected this problem. It seems that it only appears if one has a more complex (hierachical) code (i.e. a class method). I have flagged the code in question with a <<<<<<<<<------ char sequence. It will not(!) automatically be corrected even if one saves the script library and reopens it. Just copy the below class code into the Declarations Section of a new empty Scriptlibrary.
Heres ist he code:
Class sort
Firstindex As Integer
LastIndex As Integer
Mlimit As Integer
MAS As Integer
upward As Integer
Stack As StackObj
'-----------------------------------------------------
Public Sub Sort(tbl As Variant)
Dim pivot As Variant
Dim f%,l%,first%,last%,first1%,last1%,c%
Dim limits As Variant
If Me.FirstIndex<>Me.LastIndex Then
First1%=Me.FirstIndex
Last1%=Me.LastIndex
Me.Firstindex=0
Me.LastIndex=0
Else
First1%=Lbound(tbl)
Last1%=Ubound(tbl)
End If
If Me.MAS=True Then 'Multiple Array Sort: Create order array
Redim order (first1% To last1%)
For f%=first1% To last1%
order(f%)=f%
Next
End If
Redim limits(0 To 1)
limits(0)=first1%
limits(1)=last1%
Set Stack=New StackObj(10,20)
Call Stack.Push(limits)
Do While Stack.Pointer>0
Call Stack.pull (limits)
first%=limits(0)
last%=limits(1)
f%=first%
l%=last%
If last%-first%<Me.Mlimit Then 'Use above n Elements Quicksort, below Bubblesort
Bubblesort tbl, first%,last%
Else
pivot =Chosepivot (tbl, first%,last%) 'Quicksort, find a "good" center/pivot
If upward=True Then
Do '<<<<<<< ---------upward
Do While tbl(f%)<pivot
f%=f%+1
Loop
Do While tbl(l%)>pivot
l%=l%-1
Loop
If f%<=l% Then
swap tbl , f%, l%
f%=f%+1
l%=l%-1
End If
Loop While f%<l%
Else
Do '<<<<<<<--------downward
Do While tbl(f%)=>pivot
f%=f%+1
Loop
Do While tbl(l%)<pivot
l%=l%-1
Loop
If f%<=l% Then
swap tbl, f%, l%
f%=f%+1
l%=l%-1
End If
Loop While f%<l%
End If
If f%>l% Then
c%=f%
f%=l%
l%=c%
Else
If tbl(f%)>pivot Then
l%=f%
f%=f%-1
Else
l%=f%+1
End If
End If
If first%<f% Then 'lower segment
limits(0)=first%
limits(1)=f%
Call Stack.push (limits)
End If
If l%<last% Then 'upper segment
limits(0)=l%
limits(1)=last%
Call Stack.push (limits)
End If
End If
Loop
End Sub
'-----------------------------------------------------
Sub Bubblesort (tbl As Variant, first%,last%)
End Sub
'-----------------------------------------------------
Sub swap (tbl As Variant , f%, l% )
End Sub
'-----------------------------------------------------
Function Chosepivot (tbl As Variant, first%,last%)
End Function
'-----------------------------------------------------
’ . . .
End Class
Class StackObj
Private stackpointer As Integer
'-----------------------------------------------------
Sub New(Ststep%,MDepth%)
End Sub
'-----------------------------------------------------
Public Sub push(v As Variant)
End Sub
'-----------------------------------------------------
Public Sub Pull (v As Variant)
End Sub
'-----------------------------------------------------
Public Property Get Pointer As Integer
Pointer=stackpointer
End Property
'----------------------------------------------------
End Class