// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! 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; string experlist,oldexper,newexper,st,key,ID; integer i,ok,selonly,totalcount,expercount,errorcount; for i=1 to DbGetExperCount do if DbGetExperClass(i)="FPR" then experlist=experlist+DbGetExperName(i)+" "; st="This script automatically changes the fingerprint type from a number of database entries"; DlgAddText(dlg,st,20,20,240,30); DlgAddText(dlg,"Original fingerprint type:",20,60,150,15); DlgAddList(dlg,experlist,oldexper,20,80,150,150,"LIST"); DlgAddText(dlg,"New fingerprint type:",200,60,150,15); DlgAddList(dlg,experlist,newexper,200,80,150,150,"LIST"); selonly=0; DlgAddCheck(dlg,"Selected entries only",selonly,20,240,150,15); ok=0; while not(ok) do { if not(DlgShow(dlg,"Change fingerprint type",370,340)) then stop; ok=1; if (ok) and (oldexper="") then { ok=0; message("You should select an original fingerprint type"); } if (ok) and (newexper="") then { ok=0; message("You should select a new fingerprint type"); } if (ok) and (oldexper=newexper) then { ok=0; message("The original and new fingerprint types should not be the same"); } } setbusy("scanning database"); totalcount=0;expercount=0;errorcount=0; for i=1 to DbGetEntryCount do { key=DbGetEntryKey(i); if not(selonly) or DbGetSel(key) then { totalcount=totalcount+1; ID=DbGetEntryLink(key,oldexper); if ID<>"" then { expercount=expercount+1; if DbGetEntryLink(key,newexper)<>"" then errorcount=errorcount+1; } } } setbusy(""); DlgReset(dlg); DlgAddText(dlg,str(totalcount,0,0)+" entries were found in total",20,20,280,15); DlgAddText(dlg,str(expercount,0,0)+" contain the experiment '"+oldexper+"'",20,40,280,15); DlgAddText(dlg,str(errorcount,0,0)+" of these already have an experiment '"+newexper+"'",20,60,280,15); DlgAddText(dlg,"OK to proceed?",20,100,150,15); if not(DlgShow(dlg,"Change fingerprint type",320,200)) then stop; setbusy("converting"); for i=1 to DbGetEntryCount do { key=DbGetEntryKey(i); if not(selonly) or DbGetSel(key) then { ID=DbGetEntryLink(key,oldexper); if ID<>"" then { if DbGetEntryLink(key,newexper)="" then { FprChangeType(key,oldexper,newexper); } } } } setbusy("");