Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_ButtonA = 500
IDC_ButtonB = 501
End Enum
Global hDlg As Dword
Global D() As String
Function PBMain() As Long
Dialog New Pixels, 0, "PowerBASIC",300,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_ButtonA,"Push1", 50,10,100,20
Control Add Button, hDlg, %IDC_ButtonB,"Push2", 50,40,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_ButtonA
BuildD
TwoFieldSort1 1,3,":"
? Join$(D(),$CrLf)
Case %IDC_ButtonB
BuildD
TwoFieldSort2 1,3,":"
? Join$(D(),$CrLf)
End Select
End Select
End Function
Sub BuildD
ReDim D(6)
D(0) = "a:z:sy
D(6) = "a:w:tk
D(5) = "bb:z:ax
D(3) = "bb:u:ll
D(2) = "g:n:mq
D(4) = "g:b:xd
D(1) = "g:a:co
End Sub
Sub TwoFieldSort1(F1 As Long, F2 As Long, Delimiter$)
Local i,j As Long
For i = 0 To UBound(D)
D(i) = Parse$(D(i),Delimiter$,F1) + Delimiter$ + Parse$(D(i),Delimiter$,F2) + Delimiter$ + D(i)
Next i
Array Sort D()
For i = 0 To UBound(D)
j = InStr(D(i),Delimiter$)
j = InStr(j+1,D(i),Delimiter$)
D(i) = Mid$(D(i),j+1)
Next i
End Sub
Sub TwoFieldSort2(F1 As Long, F2 As Long, Delimiter$)
Local i As Long
ReDim tempD(UBound(D)) As String
For i = 0 To UBound(D)
tempD(i) = Parse$(D(i),Delimiter$,F1) + Delimiter$ + Parse$(D(i),Delimiter$,F2)
Next i
Array Sort tempD(), TagArray D()
End Sub
'gbs_01444
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm