#139730 - 2005-05-20 03:58 PM
Re: Where is my logic wrong
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Does this make any sense?
Some, but if I replace "sort" with "filter" it makes a lot more.
I'm assuming that you do mean filter, rather than sort?
If so then it is quite easy. Something like this:
Code:
; Default action is to include item $iIncludeThis=1 ; If there is a server filter and server name does not match then exclude it If $ServSort.Text<>"None" AND $ServSort.Text<>$Server $iIncludeThis=0 EndIf ; If there is a reported by filter and reported by name does not match then exclude it If $ReportSort.Text<>"None" AND $ReportSort.Text<>$BY $iIncludeThis=0 EndIf ; If there is an error by filter and error does not match then exclude it If $ErrorSort.Text<>"None" AND $ErrorSort.Text<>$E $iIncludeThis=0 EndIf ; Still interested? If $iIncludeThis ; Add to the array here... EndIf
|
Top
|
|
|
|
#139734 - 2005-05-21 09:24 AM
Re: Where is my logic wrong
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Code:
Do you concur...Code:
No. You set $iIncludeThis true in the wrong place - it will only be true once for the entire filter.
You need to set it for each entry that you will compare: Code:
Function Filter()
$Flag = "True" $Count = 0 For $count2 = 0 To UBound($c) $Comp = $C[$count2] $Re = $BY[$count2] $Err = $E[$Count2] $iIncludeThis=1 If $ServSort.Text<>"None" AND $ServSort.Text<>$Comp $iIncludeThis=0 EndIf If $ReportSort.Text<>"None" AND $ReportSort.Text<>$Rep $iIncludeThis=0 EndIf If $ErrorSort.Text<>"None" AND $ErrorSort.Text<>$ERR $iIncludeThis=0 EndIf If $iIncludeThis ReDIM Preserve $D1[$Count] ReDIM Preserve $T1[$Count] ReDIM Preserve $E1[$Count] ReDIM Preserve $C1[$count] ReDIM Preserve $TE1[$Count] ReDIM Preserve $BY1[$count] $D1[$Count] = $D[$Count2] $T1[$Count] = $T[$Count2] $E1[$Count] = $E[$Count2] $C1[$Count] = $C[$Count2] $TE1[$Count] = $TE[$Count2] $By1[$Count] = $BY[$Count2] $count = $count + 1 EndIf Next $Count = 0 Update2 ()
EndFunction
|
Top
|
|
|
|
#139735 - 2005-05-23 05:13 PM
Re: Where is my logic wrong
|
Gargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
|
Here is what finally worked for me. Turned out that it was a problem with my not Dimming some variables.
Live and learn
Code:
Function Filter() DIM $d1, $t1, $e1, $c1, $te1, $by1 DIM $d2, $t2, $e2, $c2, $te2, $by2 $ProgressBar.Visible = "True" $ProgressBar.Value = 0 $Label15.Text = "Filtering" $Flag = "True" $Count = 0 For $count2 = 0 To UBound($c) If $ProgressBar.Value => 100 $ProgressBar.Value = 0 EndIf $ProgressBar.PerformStep() $iIncludeThis=0 $Comp = $C[$count2] If $ServSort.Text = "None" OR $ServSort.Text = $Comp $iIncludeThis=1 EndIf If $iIncludeThis = 1 ReDIM Preserve $D1[$Count] ReDIM Preserve $T1[$Count] ReDIM Preserve $E1[$Count] ReDIM Preserve $C1[$count] ReDIM Preserve $TE1[$Count] ReDIM Preserve $BY1[$count] $D1[$Count] = $D[$Count2] $T1[$Count] = $T[$Count2] $E1[$Count] = $E[$Count2] $C1[$Count] = $C[$Count2] $TE1[$Count] = $TE[$Count2] $By1[$Count] = $BY[$Count2] $count = $count + 1
EndIf Next $Count = 0 For $count2 = 0 To UBound($C1) If $ProgressBar.Value => 100 $ProgressBar.Value = 0 EndIf $ProgressBar.PerformStep() $iIncludeThis=0 $Rep = $BY1[$count2] If $ReportSort.Text = "None" OR $ReportSort.Text = $Rep $iIncludeThis=1 EndIf If $iIncludeThis = 1 ReDIM Preserve $D2[$Count] ReDIM Preserve $T2[$Count] ReDIM Preserve $E2[$Count] ReDIM Preserve $C2[$count] ReDIM Preserve $TE2[$Count] ReDIM Preserve $BY2[$count] $D2[$Count] = $D1[$Count2] $T2[$Count] = $T1[$Count2] $E2[$Count] = $E1[$Count2] $C2[$Count] = $C1[$Count2] $TE2[$Count] = $TE1[$Count2] $By2[$Count] = $BY1[$Count2] $count = $count + 1
EndIf Next $Count = 0 For $count2 = 0 To UBound($C2) If $ProgressBar.Value => 100 $ProgressBar.Value = 0 EndIf $ProgressBar.PerformStep() $iIncludeThis=0 $Err = $E2[$Count2] If $ErrorSort.Text = "None" OR $ErrorSort.Text = $ERR $iIncludeThis=1 EndIf
If $iIncludeThis = 1 ReDIM Preserve $D3[$Count] ReDIM Preserve $T3[$Count] ReDIM Preserve $E3[$Count] ReDIM Preserve $C3[$count] ReDIM Preserve $TE3[$Count] ReDIM Preserve $BY3[$count] $D3[$Count] = $D2[$Count2] $T3[$Count] = $T2[$Count2] $E3[$Count] = $E2[$Count2] $C3[$Count] = $C2[$Count2] $TE3[$Count] = $TE2[$Count2] $By3[$Count] = $BY2[$Count2] $count = $count + 1
EndIf Next $Count = 0 Update2 () $ProgressBar.Visible = "False" $Label15.Text = "Filter Criteria" EndFunction
_________________________
Today is the tomorrow you worried about yesterday.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 918 anonymous users online.
|
|
|