// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! 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. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! string expername,experlist,key,fieldlist,fieldname,count; integer i,txt,bnfield,savechanges; DIALOG dlg; FILE fp; FPRINT fpr; savechanges=1; for i=1 to DbGetExperCount do if DbGetExperClass(i)="FPR" then experlist=experlist+DbGetExperName(i)+" "; expername=experlist;expername=splitstring(expername," "); for i=1 to DbGetFieldCount do fieldlist=fieldlist+DbGetFieldName(i)+" "; txt=0;bnfield=1; DlgAddText(dlg,"This scripts will create a table containing the number of bands for all selected entries.~n~nSelect a fingerprint type",20,20,280,60); DlgAddList(dlg,experlist,expername,20,80,150,150,"LIST"); DlgAddText(dlg,"Export counts to:",180,80,100,20); DlgaddCheck(dlg,"Tab delimited text file",txt,180,100,120,20); DlgaddCheck(dlg,"Database field",bnfield,180,120,120,20); DlgAddCheck(dlg,"Save changes",savechanges,180,160,120,20); if not(DlgShow(dlg,"Count number of bands",320,300)) then stop; if expername="" then { message("ERROR: you should selecte a fingerprint type"); stop; } if bnfield=1 then { fieldlist="Bands in "+expername+" (Create New) "+fieldlist; fieldname=fieldlist;fieldname=splitstring(fieldname," "); dlgreset(dlg); DlgAddText(dlg,"Select an information field",20,20,200,80); DlgAddList(dlg,fieldlist,fieldname,20,50,180,150,"LIST"); DlgAddText(dlg,"WARNING: This will overwrite the current content of the field!",20,200,150,50); if not(DlgShow(dlg,"Write counts to an information field",300,300)) then stop; if expername="" then { message("ERROR: you should select a fingerprint type"); stop; } if fieldname = "Bands in "+expername+" (Create New)" then { fieldname = "Bands in "+expername+""; DbAddField(fieldname); } for i=1 to DbGetEntryCount do { key=DbGetEntryKey(i); if DbGetSel(key) then { if (FprLoadNorm(fpr,key,expername)) then count=str(FprGetBandCount(fpr),0,0); else count="---"; DbSetField(key,fieldname,count); } } } if txt=1 then { if not(FileOpenWrite(fp,"result.txt")) then { message("ERROR: unable to create the file 'result.txt'"); stop; } FileWrite(fp,"Key Number of bands"); FileWriteLine(fp); for i=1 to DbGetEntryCount do { key=DbGetEntryKey(i); if DbGetSel(key) then { FileWrite(fp,key+" "); if (FprLoadNorm(fpr,key,expername)) then FileWrite(fp,str(FprGetBandCount(fpr),0,0)); else FileWrite(fp,"---"); FileWriteLine(fp); } } FileClose(fp); execute("notepad.exe result.txt"); } if savechanges then DbSaveFields;