// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! This script is provided "as is" by Applied Maths. ! // ! You are free to use and modify this script for your own needs. ! // ! Redistribution or reproduction of the script is prohibited. ! // ! DISCLAIMER: ! // ! Improper use of scripts may corrupt your database. ! // ! Running this script is entirely at your own responsibility. ! // ! Applied Maths accepts no lialibility for any consequences ! // ! resulting from its use. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //$DISPLAY_COMPWIN DIALOG dlg; string fieldlist,fieldname,findstr,key,st; integer i,j,isregexpr,found,processed,rs; integer foundct,foundnr[],current; if not(CmpIsPresent) then CmpAttach; if not(CmpIsPresent) then { message("Unable to attach a comparison to this script"); stop; } fieldlist="< All fields > Key "; fieldname="< All fields >"; for i=1 to DbGetFieldCount do fieldlist=fieldlist+DbGetFieldName(i)+" "; DlgAddText(dlg,"Search string:",15,15,100,15); DlgAddEdit(dlg,findstr,15,35,140,20); DlgAddText(dlg,"Search in:",15,75,100,15); DlgAddList(dlg,fieldlist,fieldname,15,95,140,140,"LIST"); isregexpr=1; DlgAddCheck(dlg,"Regular expression",isregexpr,170,35,120,20); if not(DlgShow(dlg,"Find entry in comparison",305,270)) then stop; for i=1 to CmpGetEntryCount do { key=CmpGetEntryKey(i); found=0;processed=0; if fieldname="< All fields >" then { processed=1; if isregexpr then found=regexpr(key,findstr)>0; else found=(key=findstr); for j=1 to DbGetFieldCount do { st=DbGetField(key,DbGetFieldName(j)); if isregexpr then { if regexpr(st,findstr)>0 then found=1; } else { if st=findstr then found=1; } } } if fieldname="Key" then { if isregexpr then found=regexpr(key,findstr)>0; else found=(key=findstr); processed=1; } if not(processed) then { if isregexpr then found=regexpr(DbGetField(key,fieldname),findstr)>0; else found=(DbGetField(key,fieldname)=findstr); processed=1; } if found then { foundct=foundct+1; foundnr[foundct]=i; } } if foundct=0 then { message("No match found!"); stop; } current=1; while 1 do { DlgReset(dlg); DlgAddText(dlg,str(foundct,0,0)+" matches found",15,15,150,15); DlgAddText(dlg,"Current: "+str(current,0,0),15,33,150,15); if current>1 then DlgAddButton(dlg,"< Previous",11,20,60,80,25); if current",12,110,60,80,25); DlgAddButton(dlg,"Exit",13,220,60,80,25); CmpSelectEntry(CmpGetEntryKey(foundnr[current])); rs=DlgShow(dlg,"Match results",320,130); if (rs=0) or (rs=13) then stop; if (rs=11) and (current>1) then current=current-1; if (rs=12) and (current