// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // ! 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,selct,xp,yp,xpmax,ypmax,usefield[]; string st,key,clipdata; FILE fp; selct=0; for i=1 to DbGetEntryCount do if DbGetSel(DbGetEntryKey(i)) then selct=selct+1; if selct=0 then { message("There are currently no entries selected"); stop; } DlgAddText(dlg,"There are currently "+str(selct,0,0)+" entries selected",15,12,190,15); DlgAddText(dlg,"Select field(s) you want to export:",15,32,190,15); xp=15; yp=60; for i=0 to DbGetFieldCount do { usefield[i]=1; st="Key"; if i>0 then st=DbGetFieldName(i); DlgAddCheck(dlg,st,usefield[i],xp,yp,150,15); yp=yp+22; if yp>300 then { yp=60; xp=xp+160; } if xp+150>xpmax then xpmax=xp+150; if yp+22>ypmax then ypmax=yp+22; } if xpmax<390 then xpmax=390; DlgAddButton(dlg,"Copy to clipboard",11,15,ypmax+10,100,25); DlgAddButton(dlg,"Copy to file",12,130,ypmax+10,100,25); DlgAddButton(dlg,"Cancel",13,270,ypmax+10,100,25); rs=DlgShow(dlg,"Export database fields",xpmax,ypmax+80); if rs=1 then rs=11; if rs=13 then stop; if rs=12 then { st=DbGetPath+"\export.txt"; if not(FileOpenWrite(fp,st)) then { message("ERROR: unable to create the file "+st); stop; } } st=""; if usefield[0] then st=st+key; for j=1 to DbGetFieldCount do if usefield[j] then { if st<>"" then st=st+" "; st=st+DbGetFieldName(j); } st=st+"~n"; if rs=11 then clipdata=clipdata+st; if rs=12 then FileWrite(fp,st); for i=1 to DbGetEntryCount do { if i/20=floor(i/20) then setbusy("Exporting entries - "+str(i,0,0)); if DbGetSel(DbGetEntryKey(i)) then { key=DbGetEntryKey(i); st=""; if usefield[0] then st=st+key; for j=1 to DbGetFieldCount do if usefield[j] then { if st<>"" then st=st+" "; st=st+DbGetField(key,DbGetFieldName(j)); } st=st+"~n"; if rs=11 then clipdata=clipdata+st; if rs=12 then FileWrite(fp,st); } } setbusy(""); if rs=11 then CopyClipBoard(clipdata); if rs=12 then { FileClose(fp); execute("notepad.exe "+DbGetPath+"\export.txt"); }