* FindBox * kgc parameter oView,cTitle local f f = NEW FindBoxForm() if type("cTitle") = "C" f.text = cTitle endif if type("oView") = "O" f.oView = oView endif f.Open() return ** END HEADER -- do not remove this line* * Generated on 03/04/96 * parameter bModal local f f = new FindBoxForm() if (bModal) f.mdi = .F. && ensure not MDI f.ReadModal() else f.Open() endif CLASS FindBoxForm OF FORM this.OnOpen = CLASS::SETUP this.Top = 0.2344 this.Left = 3 this.Text = "Locate Records" this.Height = 19.4111 this.Width = 50 this.OnSize = CLASS::SIZEPROC DEFINE RECTANGLE RECTANGLE2 OF THIS; PROPERTY; Top 3.5879,; Left 25,; Text "Search Rules",; ColorNormal "N/W",; Height 7.0586,; Width 22.666 DEFINE RECTANGLE RECTANGLE1 OF THIS; PROPERTY; Top 11.1758,; Left 25.1641,; Text "Search From",; ColorNormal "N/W",; Height 3.4707,; Width 22.3359 DEFINE ENTRYFIELD EF_FIND OF THIS; PROPERTY; Top 1.2939,; Left 0.6641,; Height 1.3525,; Width 48.8359,; Value "",; OnChange CLASS::EF_FIND_ONCHANGE,; MaxLength 100 DEFINE LISTBOX LB_FIELD OF THIS; PROPERTY; Top 3.9404,; Left 0.8311,; ColorNormal "N/W*",; Height 10.7061,; Width 22.502,; ColorHighLight "W+/B",; ID 101 DEFINE RADIOBUTTON RB_STANDARD OF THIS; PROPERTY; Top 4.4697,; Left 26,; Text "Standard",; ColorNormal "N/W",; Height 1.1182,; Width 15,; Value .T.,; FontBold .F.,; Group .T. DEFINE RADIOBUTTON RB_EXACT OF THIS; PROPERTY; Top 5.6465,; Left 26,; Text "Exact Length",; ColorNormal "N/W",; Height 1.1182,; Width 17.5,; Value .F.,; FontBold .F.,; Group .F. DEFINE RADIOBUTTON RB_ANYWHERE OF THIS; PROPERTY; Top 6.8232,; Left 26,; Text "Anywhere in Field",; ColorNormal "N/W",; Height 1.1172,; Width 19.833,; Value .F.,; FontBold .F.,; Group .F. DEFINE RADIOBUTTON RB_SOUNDEX OF THIS; PROPERTY; Top 8,; Left 26,; Text "Sounds Like",; ColorNormal "N/W",; Height 1.1172,; Width 20.5,; Value .F.,; FontBold .F.,; Group .F. DEFINE CHECKBOX CB_MATCH OF THIS; PROPERTY; Top 9.2939,; Left 26,; Text "Ignore Case",; ColorNormal "N/W",; Height 1.0586,; Width 19.333,; Value .F.,; FontBold .F.,; Group .T. DEFINE RADIOBUTTON RB_TOP OF THIS; PROPERTY; Top 12.0586,; Left 26.3311,; Text "Top",; ColorNormal "N/W",; Height 1.1172,; Width 15.002,; Value .T.,; FontBold .F.,; Group .T. DEFINE RADIOBUTTON RB_CURRENT OF THIS; PROPERTY; Top 13.0586,; Left 26.3311,; Text "Current Record",; ColorNormal "N/W",; Height 1.1172,; Width 18.6689,; Value .F.,; FontBold .F.,; Group .F. DEFINE ENTRYFIELD EF_FOR OF THIS; PROPERTY; Top 15.9404,; Left 0.8311,; Height 1.2939,; Width 48.502,; Value "",; OnChange CLASS::EF_FOR_ONCHANGE,; MaxLength 100 DEFINE PUSHBUTTON PB_FIND OF THIS; PROPERTY; Top 17.5879,; Left 1,; Text "&Find",; ColorNormal "N/W",; Height 1.5293,; Width 11.5,; UpBitmap "RESOURCE #858",; DisabledBitmap "RESOURCE #868",; OnClick CLASS::PB_FIND_ONCLICK,; FontBold .F.,; Group .T. DEFINE PUSHBUTTON PB_FIND_NEXT OF THIS; PROPERTY; Default .T.,; Top 17.5879,; Left 13.165,; Text "Find &Next",; ColorNormal "N/W",; Height 1.5293,; Width 13.501,; UpBitmap "RESOURCE #860",; DisabledBitmap "RESOURCE #870",; OnClick CLASS::PB_FIND_NEXT_ONCLICK,; FontBold .F.,; Enabled .F.,; Group .T. DEFINE PUSHBUTTON PB_CHECK OF THIS; PROPERTY; Top 17.5879,; Left 27.332,; Text "Check &Expr.",; ColorNormal "N/W",; Height 1.5293,; Width 11.501,; OnClick CLASS::PB_CHECK_ONCLICK,; FontBold .F.,; Group .T. DEFINE PUSHBUTTON PB_CLOSE OF THIS; PROPERTY; Top 17.5879,; Left 39.5,; Text "Cl&ose",; ColorNormal "N/W",; Height 1.5293,; Width 9.666,; UpBitmap "RESOURCE #1005",; OnClick {; form.close()},; FontBold .F.,; Group .T. DEFINE TEXT TEXT1 OF THIS; PROPERTY; Top 0.4111,; Left 0.833,; Text "Find What Data?",; ColorNormal "N/W",; Height 0.8232,; Width 17.333 DEFINE TEXT TEXT2 OF THIS; PROPERTY; Top 3.0586,; Left 0.6641,; Text "Located in Field:",; ColorNormal "N/W",; Height 0.7646,; Width 17.3359 DEFINE TEXT TEXT3 OF THIS; PROPERTY; Top 15.0586,; Left 0.8311,; Text "For What Condition?:",; ColorNormal "N/W",; Height 0.7646,; Width 25.002 DEFINE PUSHBUTTON PB_NEWFILE OF THIS; PROPERTY; Top 2.8818,; Left 19.5,; Text "",; ColorNormal "N/W",; Height 0.9414,; Width 3.833,; UpBitmap "RESOURCE #144",; OnClick CLASS::PB_NEWFILE_ONCLICK,; Group .T. DEFINE PUSHBUTTON PB_CLEAR OF THIS; PROPERTY; Top 0.1758,; Left 41.1641,; Text "&Clear",; ColorNormal "N/W",; Height 1,; Width 8.002,; OnClick CLASS::PB_CLEAR_ONCLICK,; FontBold .F.,; SpeedBar .T.,; Group .T. Procedure Setup if .not. isblank(alias()) form.lb_field.datasource = "structure" form.pb_newfile.visible = .f. else form.pb_newfile.visible = .t. endif form.oheight = form.height form.owidth = form.width return Procedure sizeproc if form.height <> form.oheight form.height = form.oheight endif if form.width <> form.owidth form.width = form.owidth endif if form.windowstate = 2 form.windowstate = 0 endif return Procedure pb_newfile_OnClick cFile = getfile("*.dbf;*.qbe;*.db") if .not. isblank(cFile) if type("form.oView") = "O" form.oView.view = cFile else form.view = cFile endif form.lb_field.datasource = "structure" endif return Procedure pb_find_onclick if class::Search(.t.) form.pb_find_next.enabled = .t. endif return Procedure pb_check_onclick class::Search(.f.) return Procedure Search parameter lFind local nErr,nRn,lFound lFound = .f. if isblank(alias()) class::pb_newfile_Onclick() else cFind1 = trim(form.ef_find.value) cFind2 = trim(form.lb_field.value) cFind3 = trim(form.ef_for.value) cAddfor = "" cExp = "" cFor = "" if isblank(cFind1) .and. isblank(cFind3) msgbox("You need to specify something to search for!","Can't Seach Yet!") form.ef_find.setfocus() return .f. endif if isblank(cFind2) .and. isblank(cFind3) msgbox("You need to select a field to search in!","Can't Seach Yet!") form.lb_field.setfocus() return .f. endif cScope = iif(form.rb_top.value,"ALL ",; iif(form.rb_current.value,"REST ","")) cType = iif(form.rb_standard.value,"=",; iif(form.rb_exact.value,"==",; iif(form.rb_anywhere.value,"$",""))) cFtype = type(cFind2) do case case cFtype = "C" if .not. left(cFind1,1) $ ['"]+"[" cFind1 = '"'+cFind1+'"' if form.cb_match.value cFind1 = "upper("+cFind1+")" cFind2 = "upper("+cFind2+")" endif endif case cFtype = "D" if left(cFind1,1) <> "{" cFind1 = "{"+cFind1+"}" endif endcase if .not. isblank(cFind1) if .not. isblank(cType) cFor = "for ("+cFind1+cType+cFind2+")" else cFor = "for (soundex("+cFind1+") == soundex("+cFind2+"))" endif endif cAddFor = iif(.not. isblank(cFind3),; iif(.not. isblank(cFor)," .and. (","for (")+cFind3+")",; "") cExp = cScope+cFor+cAddFor #ifdef DEBUG lFind = .f. #endif if .not. lFind msgbox(cExp,"Here's your LOCATE Expression") else nErr = 0 on error nErr = 1 nRn = recno() locate &cExp on error if nErr = 1 msgbox(message(),"Invalid search condition") if isblank(cFind3) form.ef_find.setfocus() else form.ef_for.setfocus() endif else if .not. found() go nRn lFound = .f. msgbox("No records found. Try 'Check Expr.', then try again","No Match!") else lFound = .t. endif endif endif endif return lFound Procedure PB_Clear_OnClick form.ef_for.value = "" form.lb_field.value = "" form.lb_field.cursel = 0 form.ef_find.value = "" form.ef_find.setfocus() return Procedure EF_FIND_OnChange if .not. isblank(this.value) form.pb_find.enabled = .t. form.pb_find_next.enabled = .f. endif Procedure EF_FOR_OnChange if .not. isblank(this.value) form.pb_find.enabled = .t. form.pb_find_next.enabled = .f. endif Procedure PB_FIND_NEXT_OnClick continue if .not. found() this.enabled = .f. form.pb_find.setfocus() endif ENDCLASS