goForm = CREATEOBJECT("clsMainForm")
goForm.Visible = .T.
goForm.SHOW()
Read EVENTS
CLOSE ALL
CLEAR ALL
RETURN
**********
Define CLASS clsMainForm AS FORM
Caption = "Phonenumbers"
AutoCenter = .T.
BorderStyle = 3
Width = 600
MinWidth = 600
MaxWidth = 600
Height = 600
MinHeight = 600
MinButton = .F.
MaxButton = .F.
Themes = .F.
ShowTips = .T.
ADD Object "lblFound" as "Label" with ;
Visible = .T. , ;
Autosize = .T. , ;
Left = 12, ;
Top = ThisForm.Height - 24, ;
Caption = "Names found ", ;
Anchor = 6
ADD Object "lblPhoneNumbers" as "Label" with ;
Visible = .T. , ;
Autosize = .T. , ;
Left = 12, ;
Top = ThisForm.Height - 48, ;
Caption = "Enter digits to search for ", ;
Anchor = 6
ADD object "txtPSearch" as "TextBox" WITH ;
Visible = .T. , ;
Left = 162, ;
Top = ThisForm.Height - 48, ;
Height = 21, ;
Width = 168, ;
Anchor = 6
ADD object "cmdSearch" as "CommandButton" WITH ;
Visible = .T. , ;
Caption = "Search", ;
Left = 360, ;
Top = ThisForm.Height - 48, ;
Height = 36, ;
Anchor = 6
PROCEDURE cmdSearch.Click()
[highlight #FCE94F] LOCAL lcPHNumber
lcPHNumber = ALLTRIM(ThisForm.txtPSearch.Value)
SELECT *, CAST(0 as Integer) as iLine, CAST(0 as Integer) as iOccurs FROM csrPhoneNumbers ;
WHERE AT(lcPHNumber, mPhoneNumber) # 0 ;
INTO CURSOR tmpPHNumbers READWRITE
SELECT tmpPHNumbers
UPDATE tmpPHNumbers SET iLine = ATLINE(lcPHNumber, mPhoneNumber), iOccurs = OCCURS(lcPHNumber, mPhoneNumber)[/highlight]
LOCATE
IF _Tally > 0
ThisForm.lblFound.Caption = "Names found : " + ALLTRIM(TRANSFORM(_Tally, "9,999,999"))
WITH ThisForm.pgfMain
.Page2.Enabled = .T.
.ActivePage = 2
.Page2.Click()
ENDWITH
ELSE
ThisForm.pgfMain.Page2.grdPhoneNumbers.Visible = .F.
= MESSAGEBOX("No data found!", 48, "Search Phonenumbers", 2500)
WITH ThisForm.pgfMain
.ActivePage = 1
.Page1.Click()
ENDWITH
ENDIF
ENDPROC
Add OBJECT cmdExit AS COMMANDBUTTON WITH;
Caption = "Exit", ;
Backcolor = RGB(192,192,192), ;
Left = ThisForm.Width - 120, ;
Top = ThisForm.Height - 48, ;
Height = 36, ;
Anchor = 4 + 8
PROCEDURE cmdExit.CLICK
ThisForm.Release()
CLEAR Events
ENDPROC
ADD OBJECT pgfMain AS PageFrame WITH;
PAGECOUNT = 2, ;
LEFT = 12, ;
TOP = 12, ;
WIDTH = THISFORM.WIDTH - 24, ;
HEIGHT = THISFORM.HEIGHT - 78, ;
Anchor = 15
PROCEDURE pgfMain.Init()
LOCAL loPage as Object
FOR i = 1 TO This.PageCount
loPage = This.Pages(i)
loPage.AddObject("grdPhoneNumbers","grdBase")
loPage.Caption = ICASE(i = 1, "Original Data","Filtered Data" )
ENDFOR
This.Page2.Enabled = .F.
This.Page1.Click()
ENDPROC
PROCEDURE pgfMain.Page1.Click()
LOCAL loPage
loPage = Thisform.pgfMain.Page1
WITH loPage.grdPhoneNumbers
.ColumnCount = -1
.RecordSource = "csrPhoneNumbers"
.Column1.Header1.Caption = "Name"
.Column1.Width = 240
WITH .Column2
.Header1.Caption = "PhoneNumbers"
.NewObject("edtComments","edtPHNumbers")
.edtComments.Visible = .T.
.CurrentControl = "edtComments"
.Width = 240
.Sparse = .F.
ENDWITH
ENDWITH
ENDPROC
PROCEDURE pgfMain.Page2.Click()
LOCAL loPage
loPage = ThisForm.pgfMain.Page2
WITH loPage.grdPhoneNumbers
.Visible = .T.
.ColumnCount = -1
.RecordSource = "tmpPHNumbers"
.Column1.Header1.Caption = "Name"
.Column1.Width = 216
WITH .Column2
.Header1.Caption = "PhoneNumbers"
.NewObject("edtComments","edtPHNumbers")
.edtComments.Visible = .T.
.CurrentControl = "edtComments"
.Width = 216
.Sparse = .F.
ENDWITH
WITH .Column3
.Header1.Caption = "Line"
.Width = 36
.FontBold = .T.
ENDWITH
WITH .Column4
.Header1.Caption = "N"
.Width = 36
.FontBold = .T.
ENDWITH
ENDWITH
ENDPROC
PROCEDURE Load()
CREATE CURSOR csrPhoneNumbers (cName C(25), mPhoneNumber M)
FOR i = 1 TO 50000
INSERT INTO csrPhoneNumbers (cName, mPhoneNumber) VALUES ("T" + SYS(2015), "+352 - " + ALLTRIM(STR(100000000 * RAND())) + " - Home")
ENDFOR
UPDATE csrPhoneNumbers SET mPhoneNumber = mPhoneNumber + CHR(13) + "+32 - " + ALLTRIM(STR(100000000 * RAND())) + " - Office"
UPDATE csrPhoneNumbers SET mPhoneNumber = mPhoneNumber + CHR(13) + "+49 - " + ALLTRIM(STR(100000000 * RAND())) + " - Cellphone"
UPDATE csrPhoneNumbers SET mPhoneNumber = mPhoneNumber + CHR(13) + "+33 - " + ALLTRIM(STR(100000000 * RAND()))
UPDATE csrPhoneNumbers SET mPhoneNumber = mPhoneNumber + CHR(13) + "+44 - " + ALLTRIM(STR(100000000 * RAND()))
LOCATE
ENDPROC
PROCEDURE Destroy()
This.cmdExit.Click()
ENDPROC
ENDDEFINE
*****
DEFINE CLASS grdBase AS Grid
Top = 12
Left = 12
Height = 600 - 84 - (4 * 12)
Width = 600 - (4 * 12)
BackColor = RGB(0, 240, 240)
RowHeight = 90
AllowRowSizing = .F.
HeaderHeight = 21
AllowHeaderSizing = .F.
DeleteMark = .F.
ReadOnly = .T.
Anchor = 15
Visible = .T.
ENDDEFINE
*****
DEFINE CLASS edtPHNumbers as EditBox
BackColor = RGB(0, 240, 240)
DisabledBackColor = RGB(0, 240, 240)
IntegralHeight = .T.
ENDDEFINE
*****