SY-10 NUMERICAL INDEXER PRINCIPLE                        (Erdogan Tan, 25/5/2001)

Every record has "FIRST POINTER" (Integer or Long). Every pointer points a data record which will be sorted. Every data records has a NEXT POINTER (Integer or  Long) which points the next record in descending order or ascending order which one is selected.

Program sorts data by using FIRST POINTER for every different value (in descending order or ascending order) at first; then, by using NEXT POINTER which points the next record.

I called this method SY-10 because of numeric sorting of values which can only have 10 numerals instead of alphanumeric sorting of 32 letters (29 Turkish letters + q,x,w). SY-32 method is developed by me, for sorting 32 Turkish computer Letters (includes q,x,w letters) and other Turkish Keyboard Characters (TK-109). SY-10 is also developed by me, for sorting values which includes numerals (0,1,2,3,4,5,6,7,8,9).

(SY = SIRALAMA YÖNTEMi, "SORTING METHOD" in Turkish.)

SY-32 is used (also developed) for ADRES 417 program (ADDRESS program) in 1996, at first.

SY-10 is developed for SKORTOTO 417 program. (POINTS CHART of Soccer League Teams in descending order.)

***

Private Sub TakimlariSirala()
Rem 15-9-2002
Rem Sort Teams by Point and Goal Average (for the Point Chart)
Rem ***
Rem PT(128) as Integer (Point Sorting)
Rem "Points-Teams Pointer Array"
Rem TS(32) as Integer (Team Sorting)
Rem "Teams-Sort Pointer Array"
Rem ***
Rem SY-10 Sorting Method - Revision 1 [ 15-9-2002 ]
Rem ***
Rem Maximum 32 teams
Rem Maximum 128 points
Rem ***
Rem TakimlariSirala= SortTeams
Rem SonTakim= Last Team, Number of Teams
Rem EskiPointer= OldPointer
Rem LigTakimDosyaNo= LeagueTeamFileNo
Rem TakimData= TeamData
Rem TakimData.Siralama= TeamData.Sort= Teamdata.Nextpointer
Rem Attigi= Goal + (by current team) (G)
Rem Yedigi= Goal - (by other team)
Rem Attigi-Yedigi = Goal Average (A)
Rem Puan= Point
Dim A As Integer
Dim G As Integer
Dim EskiPointer As Integer
ReDim PT(128) As Integer
For X = 1 To SonTakim
    Get LigTakimDosyaNo, X, TakimData
    If TakimData.Reserved < 1 Then GoTo SonrakiX
    Y = TakimData.Puan
    A = TakimData.Attigi - TakimData.Yedigi
    G = TakimData.Attigi
    EskiPointer = 0
    Rem If Y > 128 Or Y < 0 Then Y = 0 ; Rem HATA ! ERROR !
    If PT(Y) = 0 Then
       PT(Y) = X
    Else
       Z = PT(Y)
       Get LigTakimDosyaNo, Z, TakimData
       If TakimData.Attigi - TakimData.Yedigi < A Then
          Get LigTakimDosyaNo, X, TakimData
          TakimData.Siralama = Z
          Put LigTakimDosyaNo, X, TakimData
          PT(Y) = X
       Else
          If TakimData.Attigi - TakimData.Yedigi = A Then
             If TakimData.Attigi < G Then
                Get LigTakimDosyaNo, X, TakimData
                TakimData.Siralama = Z
                Put LigTakimDosyaNo, X, TakimData
                PT(Y) = X
             Else
                EskiPointer = TakimData.Siralama
                If EskiPointer = 0 Then
                   TakimData.Siralama = X
                   Put LigTakimDosyaNo, Z, TakimData
                   GoTo SonrakiX
                End If
             End If
          Else
             EskiPointer = TakimData.Siralama
             If EskiPointer = 0 Then
                TakimData.Siralama = X
                Put LigTakimDosyaNo, Z, TakimData
                GoTo SonrakiX
             End If
          End If
       End If
       If EskiPointer > 0 Then
SonrakiKontroluTekrarla:
          Get LigTakimDosyaNo, EskiPointer, TakimData
          If TakimData.Attigi - TakimData.Yedigi < A Then
             Get LigTakimDosyaNo, Z, TakimData
             TakimData.Siralama = X
             Put LigTakimDosyaNo, Z, TakimData
             Get LigTakimDosyaNo, X, TakimData
             TakimData.Siralama = EskiPointer
             Put LigTakimDosyaNo, X, TakimData
          Else
             If TakimData.Attigi - TakimData.Yedigi = A Then
                If TakimData.Attigi < G Then
                   Get LigTakimDosyaNo, Z, TakimData
                   TakimData.Siralama = X
                   Put LigTakimDosyaNo, Z, TakimData
                   Get LigTakimDosyaNo, X, TakimData
                   TakimData.Siralama = EskiPointer
                   Put LigTakimDosyaNo, X, TakimData
                Else
                   Z = EskiPointer
                   EskiPointer = TakimData.Siralama
                   If EskiPointer = 0 Then
                      TakimData.Siralama = X
                      Put LigTakimDosyaNo, Z, TakimData
                      GoTo SonrakiX
                   End If
                   GoTo SonrakiKontroluTekrarla
                End If
             Else
                Z = EskiPointer
                EskiPointer = TakimData.Siralama
                If EskiPointer = 0 Then
                   TakimData.Siralama = X
                   Put LigTakimDosyaNo, Z, TakimData
                   GoTo SonrakiX
                End If
                GoTo SonrakiKontroluTekrarla
             End If
          End If
       End If
    End If
SonrakiX:
Next X
For X = 0 To 32
    TS(X) = 0
Next X
X = 0
For Y = 128 To 0 Step -1
    If PT(Y) > 0 Then
       Z = PT(Y)
       X = X + 1
       If X <= 32 Then
          TS(X) = Z
          TS(0) = X
       End If
BirSonrakiTakimiBul:
       Get LigTakimDosyaNo, Z, TakimData
       If TakimData.Siralama > 0 And TakimData.Siralama <> Z Then
          Z = TakimData.Siralama
          If X < 32 Then
             X = X + 1
             TS(X) = Z
             TS(0) = X
             GoTo BirSonrakiTakimiBul
          Else
             Exit For
          End If
       End If
    End If
Next Y
Rem ... Data is printed as follows...
Rem For X= 1 to TS(0)
Rem Get LigTakimDosyasiAdi, TS(X), TakimData
Rem [ Print ROW (Print Current Team) ]
Rem Next X
End Sub

Private Sub PuanCetveliniGoster()
Rem 15-9-2002
For X = 1 To SonTakim
    Get LigTakimDosyaNo, X, TakimData
    TakimData.Oynadigi = 0
    TakimData.Galibiyet = 0
    TakimData.Beraberlik = 0
    TakimData.Maglubiyet = 0
    TakimData.Attigi = 0
    TakimData.Yedigi = 0
    TakimData.Puan = 0
    TakimData.Siralama = 0
    TakimData.Ortalama1 = 0
    TakimData.Ortalama2 = 0
    TakimData.Ortalama3 = 0
    TakimData.Ortalama4 = 0
    Put LigTakimDosyaNo, X, TakimData
Next X
For Y = 1 To SonMac
    Get MacDosyaNo, Y, MacData
    If MacData.Status > 0 Then
       For X = 1 To SonTakim
           Get LigTakimDosyaNo, X, TakimData
           LiginTakimAdi = Trim$(TakimData.TakimAdi)
           If Trim$(MacData.Takim1) = LiginTakimAdi Then
              TakimData.Oynadigi = TakimData.Oynadigi + 1
              TakimData.Attigi = TakimData.Attigi + MacData.Takim1Gol
              TakimData.Yedigi = TakimData.Yedigi + MacData.Takim2Gol
              If MacData.Takim1Gol > MacData.Takim2Gol Then
                 TakimData.Galibiyet = TakimData.Galibiyet + 1
                 TakimData.Puan = TakimData.Puan + 3
              Else
                 If MacData.Takim1Gol < MacData.Takim2Gol Then
                    TakimData.Maglubiyet = TakimData.Maglubiyet + 1
                 Else
                    TakimData.Beraberlik = TakimData.Beraberlik + 1
                    TakimData.Puan = TakimData.Puan + 1
                 End If
              End If
              Put LigTakimDosyaNo, X, TakimData
           Else
              If Trim$(MacData.Takim2) = LiginTakimAdi Then
                 TakimData.Oynadigi = TakimData.Oynadigi + 1
                 TakimData.Attigi = TakimData.Attigi + MacData.Takim2Gol
                 TakimData.Yedigi = TakimData.Yedigi + MacData.Takim1Gol
                 If MacData.Takim2Gol > MacData.Takim1Gol Then
                    TakimData.Galibiyet = TakimData.Galibiyet + 1
                    TakimData.Puan = TakimData.Puan + 3
                 Else
                    If MacData.Takim2Gol < MacData.Takim1Gol Then
                       TakimData.Maglubiyet = TakimData.Maglubiyet + 1
                    Else
                       TakimData.Beraberlik = TakimData.Beraberlik + 1
                       TakimData.Puan = TakimData.Puan + 1
                    End If
                 End If
                 Put LigTakimDosyaNo, X, TakimData
              End If
           End If
       Next X
   End If
Next Y
Call TakimlariSirala
Cls
Form8.Caption = "Lig" + Str$(Lig) + " Puan Cetveli  [ F10 = Yardım ]"
Y = TextWidth("0")
CurrentY = 200
CurrentX = 400
ForeColor = Renk(Kirmizi)
Print LiginAdi
CurrentX = 400
ForeColor = 0
Print "Puan Cetveli"
Print Chr$(32)
CurrentX = 400
ForeColor = Renk(Lacivert)
Print "Takımlar";
CurrentX = 2600 + Y
Print " O";
CurrentX = 3000 + Y
Print " G";
CurrentX = 3400 + Y
Print " B";
CurrentX = 3800 + Y
Print " M";
CurrentX = 4200 + Y
Print " A";
CurrentX = 4600 + Y
Print " Y";
CurrentX = 5000 + Y
Print " P"
CurrentY = CurrentY + 50
Line (400, CurrentY)-(5000 + (3 * Y), CurrentY)
CurrentY = CurrentY + 75
Z = 0
For X = 1 To TS(0)
    Get LigTakimDosyaNo, TS(X), TakimData
    Z = Z + 1
    If Z < 10 Then
       CurrentX = 100 + Y
    Else
       CurrentX = 100
    End If
    ForeColor = Renk(Lacivert)
    Print LTrim$(Z);
    Print ".";
    CurrentX = 400
    ForeColor = Renk(Mavi)
    Print Trim$(TakimData.TakimAdi);
    If TakimData.Oynadigi < 10 Then
       CurrentX = 2600 + Y
    Else
       CurrentX = 2600
    End If
    Print Str$(TakimData.Oynadigi);
    If TakimData.Galibiyet < 10 Then
       CurrentX = 3000 + Y
    Else
       CurrentX = 3000
    End If
    Print Str$(TakimData.Galibiyet);
    If TakimData.Beraberlik < 10 Then
       CurrentX = 3400 + Y
    Else
       CurrentX = 3400
    End If
    Print Str$(TakimData.Beraberlik);
    If TakimData.Maglubiyet < 10 Then
       CurrentX = 3800 + Y
    Else
       CurrentX = 3800
    End If
    Print Str$(TakimData.Maglubiyet);
    If TakimData.Attigi < 10 Then
       CurrentX = 4200 + Y
    Else
       CurrentX = 4200
    End If
    Print Str$(TakimData.Attigi);
    If TakimData.Yedigi < 10 Then
       CurrentX = 4600 + Y
    Else
       CurrentX = 4600
    End If
    Print Str$(TakimData.Yedigi);
    If TakimData.Puan < 10 Then
       CurrentX = 5000 + Y
    Else
       CurrentX = 5000
    End If
    Print Str$(TakimData.Puan)
Next X
If Form8.WindowState = 0 Then Form8.Height = CurrentY + 1000

End Sub

***

SY-32 Indexer: sy-32.html (turkish aphabetical sort)

SY-26 Indexer: sy-26.html (english alphabetical sort)

Visual Basic Projects: vbasic.html

TR-DOS & SINGLIX & MULTIX project: trdos.html