// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! 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. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DIALOG dlg; integer rs,i,j,ps1,selonly,savechanges; string st_find,st_replace,fieldlist,fieldsel,st,key; savechanges=1; fieldlist="-- All fields -- ";fieldsel="-- All fields --"; for i=1 to DbGetFieldCount do fieldlist=fieldlist+DbGetFieldName(i)+" "; DlgAddText(dlg,"Find text:",15,15,80,15); DlgAddEdit(dlg,st_find,100,15,150,19); DlgAddText(dlg,"Replace by:",15,55,80,15); DlgAddEdit(dlg,st_replace,100,55,150,19); DlgAddText(dlg,"Search in:",15,95,80,15); DlgAddList(dlg,fieldlist,fieldsel,100,95,150,100,"DROP"); DlgAddCheck(dlg,"Selection only",selonly,15,150,100,15); DlgAddCheck(dlg,"Save changes",savechanges,15,180,100,15); rs=DlgShow(dlg,"Find and replace",265,240); if rs<>1 then stop; if savechanges then { Sleep(300); DlgReset(dlg); DlgAddText(dlg,"WARNING: pressing 'Yes' will permanently change",15,15,250,15); DlgAddText(dlg,"the database on your computer !",15,32,250,15); DlgAddText(dlg,"OK to proceed?",15,70,250,15); DlgAddButton(dlg,"No",12,150,120,80,25); DlgAddButton(dlg,"Yes",11,30,120,80,25); i=DlgShow(dlg,"CONFIRMATION",300,190); if i<>11 then stop; } for i=1 to DbGetEntryCount do { if i/20=floor(i/20) then setbusy("Scanning database - "+str(i,0,0)); key=DbGetEntryKey(i); if (not(selonly)) or (DbGetSel(key)=1) then { for j=1 to DbGetFieldCount do if (fieldsel="-- All fields --") or (DbGetFieldName(j)=fieldsel) then { st=DbGetField(key,DbGetFieldName(j)); ps1=find(st,st_find,1); if ps1>0 then { st=substring(st,1,ps1-1)+st_replace+substring(st,ps1+length(st_find),10000); DbSetField(key,DbGetFieldName(j),st); } } } } setbusy(""); if savechanges then DbSaveFields;