Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_ButtonI = 500
IDC_ButtonR
IDC_ButtonC
End Enum
Global hDlg As Dword, D() As String
Function PBMain() As Long
Dialog New Pixels, 0, "Test",1000,300,200,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_ButtonI,"Show Initial Array", 50,10,100,20
Control Add Button, hDlg, %IDC_ButtonR,"Remove Row 2", 50,40,100,20
Control Add Button, hDlg, %IDC_ButtonC,"Remove Col 2", 50,70,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local qStart, qStop As Quad
Static qFreq As Quad
Select Case Cb.Msg
Case %WM_InitDialog
QueryPerformanceFrequency qFreq
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_ButtonI
Initialize
? ArrayContent(D()),%MB_Ok,"Array Data"
Case %IDC_ButtonR
Initialize
QueryPerformanceCounter qStart
RemoveRow(D(), 2)
QueryPerformanceCounter qStop
Dialog Set Text hDlg, "Test " + Format$((qStop-qStart)/qFreq,"###.000") & "s"
? ArrayContent(D())
Case %IDC_ButtonC
Initialize
QueryPerformanceCounter qStart
RemoveCol(D(),2)
QueryPerformanceCounter qStop
Dialog Set Text hDlg, "Test " + Format$((qStop-qStart)/qFreq,"###.000") & "s"
? ArrayContent(D())
End Select
End Select
End Function
Sub Initialize
Local iCol,iRow,MaxCol,MaxRow As Long
MaxCol = 20
MaxRow = 50000
ReDim D(1 To MaxCol,1 To MaxRow)
For iCol = 1 To MaxCol
For iRow = 1 To MaxRow
D(iCol,iRow) = Format$((iRow-1)*MaxCol + iCol,"00")
Next iRow
Next iCol
End Sub
Function ArrayContent(T() As String) As String
Local temp$, iCol,iRow As Long
For iRow = 1 To UBound(T,2)
temp$ += $CrLf
For iCol = 1 To UBound(T,1)
temp$ += Format$(Val(T(iCol,iRow)),"00")+$Spc
Next iCol
Next iRow
Function = temp$
End Function
Sub RemoveRow(T() As String, iRow As Long)
Local i,j As Long
For i = 1 To UBound(T,1)
For j = iRow To UBound(T,2)-1
T(i,j) = T(i,j+1)
Next j
Next i
ReDim Preserve T(1 To UBound(T,1),1 To UBound(T,2)-1)
End Sub
Sub RemoveCol(T() As String, iCol As Long)
Local i,j As Long
Dim TX(1 To UBound(T,2),1 To UBound(T,1)) As String
For i = 1 To UBound(T,1)
For j = 1 To UBound(T,2)
TX(j,i) = T(i,j)
Next j
Next i
RemoveRow(TX(),iCol)
ReDim T(1 To UBound(TX,2), 1 To UBound(TX,1))
For i = 1 To UBound(TX,1)
For j = 1 To UBound(TX,2)
T(j,i) = TX(i,j)
Next j
Next i
End Sub
'gbs_01387
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm