DIALOG dlg; integer i,j,k,selct,xp,yp,xpmax,ypmax,usefield[],unitCnt,indb; string st,key,clipdata,line,fields,libName,unit[],keyList[]; FILE fp,old,new; INDEX unitIdx; // initialize settings fields = "0000"; 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,320,15); DlgAddText(dlg,"Library name:",15,32,80,15); DlgAddEdit(dlg,libName,100,30,100,15); DlgAddCheck(dlg,"Store in connected database",indb,15,60,320,15); DlgAddText(dlg,"Select field(s) to create library units:",15,90,320,15); xp=15; yp=120; for i=1 to DbGetFieldCount do { usefield[i]=val(substring(fields,i+1,i+1)); st=DbGetFieldName(i); DlgAddCheck(dlg,st,usefield[i],xp,yp,150,15); yp=yp+22; if yp>300 then { yp=120; 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; if not(DlgShow(dlg,"Create library units",xpmax,ypmax+80)) then stop; //// new settings //st = ""; //for i = 0 to DbGetFieldCount do st = st + str(usefield[i],0,0); //FileOpenRead(old,GetScriptName); //FileOpenWrite(new,GetScriptName+".tmp"); //line = FileRead(old,1000); //while not(FileIsEnd(old)) do { // if substring(line,1,9) = "fields = " then line = "fields = ~""+st+"~";"; // FileWrite(new,line); FileWriteLine(new); // line = FileRead(old,1000); //} //FileClose(old);FileClose(new); //FileCopy(GetScriptName+".tmp",GetScriptName); //FileDelete(GetScriptName+".tmp"); // get units and keylists unitCnt = 0; for i=1 to DbGetEntryCount do { if DbGetSel(DbGetEntryKey(i)) then { key = DbGetEntryKey(i); st = ""; for j=1 to DbGetFieldCount do if usefield[j] then st = st + DbGetField(key,DbGetFieldName(j)) + " "; if not(IdxGet(unitIdx,st)) then { unitCnt = unitCnt + 1; unit[unitCnt] = st; IdxSet(unitIdx,st,unitCnt); keyList[unitCnt] = ""; } k = IdxGet(unitIdx,st); keyList[k] = keyList[k] + key + " "; } } if ConnDbGetDefault="" then indb=0; // create library if not(find(LibGetList,libName,1)) then LibCreate(libName,indb); for i = 1 to unitCnt do LibAddUnit(libName,unit[i],keyList[i]);