// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! 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. ! // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! integer i,j,idx; DIALOG dlg; string experlist,expername; integer charcount,entrycount; float vl; string charname[]; integer charpres[],charpos[]; float charsum[],charsum2[]; float mean,stdev; CHARSET cs; string filename; FILE fl; for i=1 to DbGetExperCount do if dbGetExperClass(i)="CHR" then { if length(expername)=0 then expername=DbGetExperName(i); experlist=experlist+DbGetExperName(i)+" "; } DlgAddText(dlg,"Select character type:",15,15,150,15); DlgAddList(dlg,experlist,expername,15,35,150,150,"LIST"); if not(DlgShow(dlg,"Query by character value",280,217)) then stop; charcount=ChrSetGetCount(expername); for i=1 to charcount do { charname[i]=ChrSetGetChar(expername,i); charpres[i]=0; charpos[i]=0; charsum[i]=0.0; charsum2[i]=0.0; } entrycount=0; for i=1 to DbGetEntryCount do if DbGetSel(DbGetEntryKey(i)) then { if ChrLoad(cs,DbGetEntryKey(i),expername) then { entrycount=entrycount+1; for j=1 to charcount do { idx=ChrFindName(cs,charname[j]); if (idx>0) and ChrGetPresent(cs,idx) then { vl=ChrGetVal(cs,idx); charpres[j]=charpres[j]+1; if vl>0.0 then charpos[j]=charpos[j]+1; charsum[j]=charsum[j]+vl; charsum2[j]=charsum2[j]+vl*vl; } } } } if entrycount=0 then { message("No character sets selected"); stop; } filename="result.txt"; if not(FileOpenWrite(fl,filename)) then { message("Unable to write to the file~n"+filename); stop; } FileWrite(fl,"Name Present Positive Mean Stdev~n"); for i=1 to charcount do { FileWrite(fl,charname[i]+" "); FileWrite(fl,str(charpres[i]/entrycount*100,0,2)+" "); if charpres[i]<=0 then charpres[i]=1; FileWrite(fl,str(charpos[i]/charpres[i]*100,0,2)+" "); mean=charsum[i]/charpres[i]; FileWrite(fl,str(mean,0,4)+" "); stdev=charsum2[i]/charpres[i]-mean*mean; if stdev>0 then stdev=stdev^0.5; FileWrite(fl,str(stdev,0,4)); FileWriteLine(fl); } FileClose(fl); execute("notepad.exe "+filename);