/* COPYELEM (STD) -- Copy DDB File Elements */ /* COPYELEM (STD) -- DDB-Dateielemente kopieren */ /* // Copyright (c) 2000-2012 Oliver Bartels F+E, Muenchen // Author: Roman Ludwig // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (091020) RELEASED FOR BAE V7.4. // rl (091009) ENHANCEMENT: // Added logical library copy option for schematic sheet symbols. // Added symbol name conflict resolving to schematic sheet copy. // rl (081014) RELEASED FOR BAE V7.2. // rl (080602) ENHANCEMENT: // Added packager parameter copy to project/layout copy. // rl (080422) ENHANCEMENT: // Added destination file name suggestion. // rl (071029) RELEASED FOR BAE V7.0. // rl (070726) ENHANCEMENT: // Added project recover option. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (040427) CHANGE: // Allowed selection of non .DDB files like .BAK as source. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (000723) RELEASED FOR BAE V4.6. // mb (000723) CHANGE: // Copied elements count message at end of copy process. // mb (000723) CHANGE: // Prevent copy if source and destination file names equal. // mb (000723) CHANGE: // Merge mode selection postponed until after destination // file name selection; merge mode only to be selected // if destination file element class exists (otherwise // merge destination default mode is used). // mb (000723) CHANGE: // Abort if no elements selected for copy. // mb (000723) CHANGE: // Adapted to new popupmulmenu function definition. // rl (000221) ORIGINAL CODING: // Retrieved from LOADELEM. // // DESCRIPTION // // The copyelem User Language program copies menu-selectable // elements from one DDB file to another, thus providing facilities // similar to the copyddb Utility program. The popup menu for // selecting multiple source file elements of the chosen DDB class // allows for wildcard element name specifications such as, e.g., // "74ls*" for SCM symbols or "dil*" for layout part symbols. // The copy/merge mode (Copy All for overwriting existing destination // file elements or No Replacements for keeping existing destination // file elements) must be selected after specifying an existing // destination file containing elements of the chosen DDB class. // With SCM symbols selected, there is also an option for // copying symbol-specific logical library definitions. */ // Includes #include "pop.ulh" // User Language popup utilities #include "sql.ulh" // User Language SQL utilities // Enforce editor caller type #pragma ULCALLEREDT // Disable undo state request #pragma ULCALLERNOUNDO // Messages string UPRABORT = M_UPRABORT(); string UPRSFILE = M("Quelldateiname ? ","Source File Name ? "); string UPRDFILE = M("!Zieldateiname ? ","!Destination File Name ? "); string WRNFNEQUAL = M("Quelldatei '%s' kann nicht als Zieldatei gewaehlt werden!", "Destination file must be different from source file '%s'!"); string UPRSELELEM = M("Elementname/-muster ? ","Element Name/Pattern ? "); string UPRSELMERGE = M("Modus fuer in der Zieldatei vorhandene Elemente waehlen!", "Select Mode for Elements already existing in Destination!"); string UPRSELCLASS = M("Elementklasse selektieren!", "Select Element Class!"); string UPRCLSCM = M("&Plan","S&heet"); #define UPRCLSSYM "&Symbol" #define UPRCLSLAB "&Label" #define UPRCLSMRK "&Marker" string UPRCLLLIB = M("%Lo&giche Bibliothek","%Lo&gical Library"); #define UPRCLLAY "&Layout" string UPRCLLPRT = M("&Bauteil","&Part"); #define UPRCLLSTK "Pad&stack" #define UPRCLLPAD "Pa&d" #define UPRCLILAY "Chip &Layout" string UPRCLICELL = M("Chip Standard-&Zelle","Chip Standard &Cell"); #define UPRCLIPIN "Chip &Pin" string UPRPROJECT = M("%Pro&jektkopie","%Copy Pro&ject"); string UPRRECOVER = M("Projekt&rettung","Project &Recovery"); string UPRSQLDB = M("%S&QL-Datenbank","%S&QL Database"); string UPRMERGES = M("&Alles kopieren","Copy &All"); string UPRMERGED = M("&Keine Ersetzungen","&No Replacements"); string UPRLOGCOPY = M("Logische Bibliothek gefunden. Mitkopieren ?", "Logical Library found. Copy ?"); string UPRNOSCM = M("&Keine Schaltplaene kopieren", "&Don't copy schematic sheets"); string UPRSCMCOPY = M("&Schaltplaene kopieren", "&Copy schematic sheets"); string UPRNOLLIB = M("&Keine logischen Definitionen kopieren", "&Don't copy logical library"); string UPRLLIBCOPY = M("&Logische Definitionen kopieren", "&Copy logical library"); string UPRNOLAY = M("&Keine Layouts kopieren","&Don't copy layouts"); string UPRLAYCOPY = M("&Layout kopieren","&Copy layout"); string UPRLAYSCOPY = M("&Einzellayout kopieren","&Copy single layout"); string UPRLAYACOPY = M("&Alle Layouts kopieren","&Copy all layouts"); string UPRNOSQL = M("&Keine SQL-Datenbanken kopieren", "&Don't copy SQL databases"); string UPRSQLCOPY = M("&SQL-Datenbanken kopieren", "&Copy SQL databases"); string UPRCOPYNAME = M("_kopie","_copy"); string UPRCOPYSET = M("Projektkopie Datensaetze", "Project Copy Data Sets"); string REPSOURCE = M("Elementklasse '%s', Datei '%s'", "Element class '%s', File '%s'"); string REPCOPY = M("Kopieren '%s'...","Copying '%s'..."); string REPCOPYREC = M("Zwischenkopie nach '%s'...","Temporary Copy to '%s'..."); string REPCOPYDONE = M("%d Element(e) von '%s' nach '%s' kopiert.", "%d element(s) copied from '%s' to '%s'."); string REPPCOPYDONE = M("Inhalt von '%s' nach '%s' kopiert.", "Copied content from '%s' to '%s'."); string REPECOPY = M("Kopiere %s '%s'...","Copying %s '%s'..."); string REPLCOPY = M("Kopiere Layout '%s'...","Copying layout '%s'..."); string REPSCOPY = M("Kopiere Schaltplan '%s'...", "Copying schematic '%s'..."); string REPBCOPY = M("Kopiere logische Definitionen...", "Copying logical library..."); string REPTCOPY = M("Kopiere Tabelle '%s'...","Copying table '%s'..."); string REPLOGCOPY = M("Projektbereinigung :","Project Cleanup :"); string REPLOGRECOVER = M("Projektrettung :","Project Recovery :"); string REPLOGSFILE = M(" Quelldatei .......: '%s'", " Source File ......: '%s'"); string REPLOGDFILE = M(" Zieldatei ........: '%s'", " Destination File .: '%s'"); string ERRCOPY = M("Fehler beim Kopieren von Element '%s'!", "Error copying element '%s'!"); string ERRECOPY = M("Fehler beim Kopieren von %s '%s'!", "Error copying %s '%s'!"); string ERRDSTEXISTS = M("Zieldatei '%s' bereits vorhanden!", "Destination file '%s' already exists!"); string ERRILLDATA = M("Unbekannter Datentyp in Tabelle!", "Table contains unknown data type!"); string ERRFREAD = M("Fehler beim Lesen der Datei '%s'!", "Error reading file '%s'!"); string ERRFWRITE = M("Fehler beim Schreiben auf Datei '%s'!", "Error writing to file '%s'!"); // SQL command definitions #define CMD_GETDATA "select from %s;" #define CMD_INSDATA "quickinsert into %s values(" #define CMD_IDXDATA "index table %s;" // Globals #define BAKEXT ".bak" // Backup file extension #define TMPFILE "ddbrecover.ddb"// Recovery temporary file name #define UL_DBCOPY "dbcopy" // ULP: SQL/DB Copy STRINGS datal /* Data list string */; int datan /* Data list count */; string sqlicommand /* SQL insert command string */; string curdtab /* Current destination table name */; STRINGS msgl /* Message list */; int msgn = 0 /* Message count */; STRINGS hl /* Popup menu header list */; int hn /* Popup menu header count */; // Main program void main() { STRINGS headl /* Header string list */; int headn /* Header string count */; STRINGS entryl /* Entry string list */; int entryn = 0 /* Entry list */; STRINGS selentryl /* Selected entry string list */; int selentryn = 0 /* Selected entry count */; string sfn /* Source file name */; string dfn = "" /* Destination file name */; string ename /* Element name buffer */; string msg /* Message buffer */; string bfn /* Backup file name */; int refcnt /* Reference entry count */; int refidx /* Reference entry index */; int refclass /* Reference entry class */; string refname /* Reference entry name */; int merge = 0 /* Merge mode */; int loglflag = (-1) /* Loglib flag */; int sheetflag = 0 /* Sheet copy flag */; int ddbcl = DDBCLUNDEF /* Plan DDB class */; int copycount /* Copy count */; int winflag = (bae_swconfig(3)==1 || bae_swconfig(3)==2) /* Windows environment flag */; int i /* Loop control variable */; // Test the current UL interpeter type bae_promptdialog(UPRSELCLASS); switch (uliptype()) { // Schematic Editor case ULIPSCM : // Select the SCM plan DDB class switch (bae_askmenu(9,UPRCLSCM,UPRCLSSYM,UPRCLSLAB,UPRCLSMRK, UPRCLLLIB,UPRPROJECT,UPRRECOVER,UPRSQLDB,UPRABORT)) { /* Plan */ case 0 : ddbcl=DDBCLSCM; break; /* Symbol */ case 1 : ddbcl=DDBCLSSYM; break; /* Label */ case 2 : ddbcl=DDBCLSLAB; break; /* Marker */ case 3 : ddbcl=DDBCLSMRK; break; /* Log.Lib.*/case 4 : ddbcl=DDBCLLLIB; break; /* Project */case 5 : projectcopy(); exit(0); /* Recover */case 6 : projectrecover(); exit(0); // SQL/DB report case 7 : runulprogexit(UL_DBCOPY); } break; // Layout Editor or CAM Processor case ULIPGED : case ULIPCAM : // Select the layout plan DDB class switch (bae_askmenu(8,UPRCLLAY,UPRCLLPRT,UPRCLLSTK,UPRCLLPAD, UPRPROJECT,UPRRECOVER,UPRSQLDB,UPRABORT)) { /* Layout */ case 0 : ddbcl=DDBCLLAY; break; /* Part */ case 1 : ddbcl=DDBCLLPRT; break; /* Stack */ case 2 : ddbcl=DDBCLLSTK; break; /* Pad */ case 3 : ddbcl=DDBCLLPAD; break; /* Project */case 4 : projectcopy(); exit(0); /* Recover */case 5 : projectrecover(); exit(0); // SQL/DB report case 6 : runulprogexit(UL_DBCOPY); } break; // Autorouter case ULIPAR : // May load layout plan only ddbcl=DDBCLLAY; break; // Chip Editor case ULIPCED : // Select the IC design plan DDB class switch (bae_askmenu(4, UPRCLILAY,UPRCLICELL,UPRCLIPIN,UPRABORT)) { /* IC Layout */ case 0 : ddbcl=DDBCLILAY; break; /* IC Cell */ case 1 : ddbcl=DDBCLICELL; break; /* IC Pin */ case 2 : ddbcl=DDBCLIPIN; break; } break; // CAM View case ULIPCV : break; } // Check the element class if (ddbcl==DDBCLUNDEF) // Abort error_abort(); // Select the source DDB file if (bae_askfilename(sfn,winflag ? ".ddb;*.bak" : "",UPRSFILE) || sfn=="") // Abort error_abort(); // Scan all elements ename=""; while (scanddbenames(sfn,ddbcl,ename)==1) { entryl[entryn]=ename; entryn++; } // Build the popup menu header sprintf(headl[0],REPSOURCE,ddbclassname(ddbcl),sfn); headn=1; // Show the multiple selection menu bae_setintpar(16,5017); popupmulmenu(1,0,UPRSELELEM,headl,headn,entryl,entryn, 0,-1,headn+entryn+2,100,selentryl,selentryn,0); // Abort if no elements selected for copy if (selentryn<=0) error_abort(); // Select destination file different from source file dfn=convstring(sfn,0)+UPRCOPYNAME+DDBEXT; do { // Select destination file name if (bae_askddbfname(dfn,2,UPRDFILE)) // Abort error_abort(); // Check against source file name if (dfn==sfn) { // Don't allow for source file name selection sprintf(dfn,WRNFNEQUAL,sfn); bae_msgbox(1,dfn,""); dfn=""; } } while (dfn==""); // Test if destination elements exist if (ddbcheck(dfn,ddbcl,"")==0 || ((ddbcl==DDBCLSSYM || ddbcl==DDBCLSCM) && ddbcheck(dfn,DDBCLLLIB,"")==0)) { // Select merge mode bae_promptdialog(UPRSELMERGE); switch (bae_askmenu(3,UPRMERGES,UPRMERGED,UPRABORT)) { // Merge source case 0 : merge=1; break; // Merge destination case 1 : merge=0; break; default : error_abort(); } } sheetflag= (ddbcl==DDBCLSCM && ddbcheck(dfn,DDBCLSCM,"")==0) ? 1 : 0 ; bfn=convstring(dfn,0)+BAKEXT; // Iterate selected elements for (copycount=i=0;i1) break; } // Flush scan cache scanddbenames(sfn,0,""); // Get table names tabn=sql_gettabs(sfn,tabl); // Check for dialog support if (bae_dialclr()) { // Get schematic copy mode if ((smode=bae_askmenu(3,UPRNOSCM,UPRSCMCOPY,UPRABORT))<0 || smode>1) error_abort(); // Get layout copy mode if ((lmode=bae_askmenu(4,UPRNOLAY,UPRLAYSCOPY,UPRLAYACOPY, UPRABORT))<0 || lmode>2) error_abort(); // Get logical library copy mode if ((bmode=bae_askmenu(3,UPRNOLLIB,UPRLLIBCOPY,UPRABORT))<0 || bmode>1) error_abort(); // Get database copy mode if ((dmode=bae_askmenu(3,UPRNOSQL,UPRSQLCOPY,UPRABORT))<0 || dmode>1) error_abort(); } else { // Init. the y coordinate cy=DIAL_TOPMARG; if (scnt) smidx=dial_toggle(smode,0.0,cy,UPRSCMCOPY); else smode=0; if (lcnt==1) { lmidx=dial_toggle(lmode,0.0,cy,UPRLAYCOPY); } else if (lcnt>1) { lmidx=bae_dialaddcontrol(PA_RBF,0,0,lmode,0.0,0.0, 0.0,"",0,DIAL_LEFTMARG,cy,0.0,UPRNOLAY); cy+=DIAL_CTRVSTEP; bae_dialaddcontrol(PA_RBN,1,0,0,0.0,0.0, 0.0,"",0,DIAL_LEFTMARG,cy,0.0,UPRLAYSCOPY); cy+=DIAL_CTRVSTEP; bae_dialaddcontrol(PA_RBN,2,0,0,0.0,0.0, 0.0,"",0,DIAL_LEFTMARG,cy,0.0,UPRLAYACOPY); cy+=DIAL_CTRVSTEP; } else lmode=0; if (bcnt) bmidx=dial_toggle(bmode,0.0,cy,UPRLLIBCOPY); else bmode=0; if (tabn>0) dmidx=dial_toggle(dmode,0.0,cy,UPRSQLCOPY); else dmode=0; // Store the OK and abort button with seperator dial_hsep(cy); dial_okabort(cy); // Call the dialog function bae_setintpar(16,5002); if (bae_dialaskparams(UPRCOPYSET,0,DIAL_LEFTMARG+25.0,cy)) error_abort(); // Get data from dialog box entries if (scnt) bae_dialgetdata(smidx,smode,0.0,""); if (lcnt) bae_dialgetdata(lmidx,lmode,0.0,""); if (bcnt) bae_dialgetdata(bmidx,bmode,0.0,""); if (tabn>0) bae_dialgetdata(dmidx,dmode,0.0,""); } if (lmode==1 && lcnt==1) lmode=2; if (lmode==1) { if (bae_askddbename(layname,sfn,DDBCLLAY,"")) error_abort(); sprintf(msg,REPLCOPY,layname); bae_prtdialog(msg); if (ddbcopyelem(sfn,dfn,DDBCLLAY,layname,0)) { sprintf(msgl[msgn],ERRECOPY, ddbclassname(DDBCLLAY),layname); msgn++; } ddbcopyelem(sfn,dfn,-DDBCLPCON,layname+"_log",0); ddbcopyelem(sfn,dfn,-DDBCLLECN,layname,0); ddbcopyelem(sfn,dfn,-DDBCLPPAR,"packpar",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,layname,0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[part]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[padstack]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[pad]",0); } else if (lmode==2) { // Scan for layout elements ename=""; while (scanddbenames(sfn,DDBCLLAY,ename)==1) { sprintf(msg,REPLCOPY,ename); bae_prtdialog(msg); if (ddbcopyelem(sfn,dfn,DDBCLLAY,ename,0)) { sprintf(msgl[msgn],ERRECOPY, ddbclassname(DDBCLLAY),ename); msgn++; } ddbcopyelem(sfn,dfn,-DDBCLPCON,ename+"_log",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,ename,0); } ename=""; while (scanddbenames(sfn,DDBCLLAY,ename)==1) ddbcopyelem(sfn,dfn,-DDBCLLECN,ename,0); ddbcopyelem(sfn,dfn,-DDBCLPPAR,"packpar",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[part]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[padstack]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[pad]",0); } if (smode) { // Scan for schematic plan elements ename=""; while (scanddbenames(sfn,DDBCLSCM,ename)==1) { sprintf(msg,REPSCOPY,ename); bae_prtdialog(msg); if (ddbcopyelem(sfn,dfn,DDBCLSCM,ename,0)) { sprintf(msgl[msgn],ERRECOPY, ddbclassname(DDBCLSCM),ename); msgn++; } ddbcopyelem(sfn,dfn,DDBCLPARSET,ename,0); } ddbcopyelem(sfn,dfn,-DDBCLRULL,"scm",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[plan]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[symbol]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[label]",0); ddbcopyelem(sfn,dfn,DDBCLPARSET,"[label]",0); } if (bmode) { // Scan for logical library elements ename=""; bae_prtdialog(REPBCOPY); while (scanddbenames(sfn,DDBCLLLIB,ename)==1) if (ddbcopyelem(sfn,dfn,DDBCLLLIB,ename,0)) { sprintf(msgl[msgn],ERRECOPY, ddbclassname(DDBCLLLIB),ename); msgn++; } } if (dmode) { for (i=0;i0) { // Display data output report header sprintf(hl[0],REPLOGCOPY); sprintf(hl[2],REPLOGSFILE,sfn); sprintf(hl[3],REPLOGDFILE,dfn); hl[1]=hl[4]=""; hn=5; // Display log with popup menu popupmenu(0,"",hl,hn,msgl,msgn, UINPOPABORT,0,-1,-1,hn+msgn+2,100,0,UINPOPABORT); } sprintf(msg,REPPCOPYDONE,sfn,dfn); bae_prtdialog(msg); } void projectrecover() // Recover project file { sql_fields srcfl /* Source table field list */; int srcfn /* Source table field count */; STRINGS tabl /* Table name list */; int tabn = 0 /* Table count */; string msg /* Message buffer */; string ifn = bae_planfname()/* Input file name */; string sfn /* Source file name */; string dfn /* Destination file name */; int sfh, dfh /* File handles */; int c /* Character buffer */; int i /* Loop control variable */; // Select the source DDB file if (bae_askddbfname(ifn,0,UPRSFILE)) // Abort error_abort(); sfn=strextractfilepath(ifn)+TMPFILE; // Set the error mode fseterrmode(0); // Check if temporary file already exsits if ((sfh=fopen(sfn,0))!=(-1)) { fclose(sfh); fseterrmode(1); errormsg(ERRDSTEXISTS,sfn); } fseterrmode(1); // Select destination file name dfn=convstring(ifn,0)+UPRCOPYNAME+DDBEXT; if (bae_askddbfname(dfn,2,UPRDFILE)) // Abort error_abort(); // Set the error mode fseterrmode(0); // Check if destination already exsits if ((dfh=fopen(dfn,0))!=(-1)) { fclose(dfh); fseterrmode(1); errormsg(ERRDSTEXISTS,dfn); } fseterrmode(1); // Open the source file for binary read sfh=bae_fopen(ifn,3); // Open the destination file for binary write dfh=bae_fopen(sfn,4); sprintf(msg,REPCOPYREC,sfn); bae_prtdialog(msg); // Copy first header fragment for (i=0;i<152;i++) if ((c=fgetc(sfh))==(-1) || fputc(c,dfh)) { // File write error fclose(sfh); fclose(dfh); errormsg(ERRFWRITE,dfn); } // Replace header flags fragment for (i=0;i<6;i++) if ((c=fgetc(sfh))==(-1) || fputc(0,dfh)) { // File write error fclose(sfh); fclose(dfh); errormsg(ERRFWRITE,dfn); } // Repetively get characters from input file while ((c=fgetc(sfh))!=(-1)) { // Write the current character to the output file if (fputc(c,dfh)) { // File write error fclose(sfh); fclose(dfh); errormsg(ERRFWRITE,dfn); } } // Check for read errors if (!feof(sfh)) { // Read error fclose(sfh); fclose(dfh); errormsg(ERRFREAD,sfn); } // Close the files fclose(sfh); fclose(dfh); // Get table names tabn=sql_gettabs(sfn,tabl); // Copy DDB element classes copyclass(sfn,dfn,DDBCLSCM); copyclass(sfn,dfn,DDBCLSSYM); copyclass(sfn,dfn,DDBCLSLAB); copyclass(sfn,dfn,DDBCLSMRK); copyclass(sfn,dfn,-DDBCLSPLST); copyclass(sfn,dfn,DDBCLLAY); copyclass(sfn,dfn,DDBCLLPRT); copyclass(sfn,dfn,DDBCLLSTK); copyclass(sfn,dfn,DDBCLLPAD); copyclass(sfn,dfn,-DDBCLPCON); copyclass(sfn,dfn,-DDBCLLDRC); copyclass(sfn,dfn,DDBCLPARSET); copyclass(sfn,dfn,DDBCLRULE); copyclass(sfn,dfn,DDBCLRULS); copyclass(sfn,dfn,-DDBCLRULL); copyclass(sfn,dfn,DDBCLLLIB); copyclass(sfn,dfn,DDBCLILAY); copyclass(sfn,dfn,DDBCLICELL); copyclass(sfn,dfn,DDBCLIPIN); copyclass(sfn,dfn,-DDBCLASET); copyclass(sfn,dfn,-DDBCLAPAR); copyclass(sfn,dfn,-DDBCLPPAR); copyclass(sfn,dfn,-DDBCLPPINF); copyclass(sfn,dfn,-DDBCLLECN); copyclass(sfn,dfn,-DDBCLIECN); // Copy SQL tables for (i=0;i0) { // Display data output report header sprintf(hl[0],REPLOGRECOVER); sprintf(hl[2],REPLOGSFILE,ifn); sprintf(hl[3],REPLOGDFILE,dfn); hl[1]=hl[4]=""; hn=5; // Display log with popup menu popupmenu(0,"",hl,hn,msgl,msgn, UINPOPABORT,0,-1,-1,hn+msgn+2,100,0,UINPOPABORT); } sprintf(msg,REPPCOPYDONE,ifn,dfn); bae_prtdialog(msg); } void copyclass(string sfn,string dfn,int class) /* // Copy all DDB elements of given class // Parameters : // string sfn : Source file name // string dfn : Destination file name // int class : DDB element class */ { string ename = "" /* Element name buffer */; string msg /* Message buffer */; // Scan for elements while (scanddbenames(sfn,class,ename)==1) { sprintf(msg,REPECOPY,ddbclassname(class),ename); bae_prtdialog(msg); if (ddbcopyelem(sfn,dfn,-class,ename,0)) { sprintf(msgl[msgn],ERRECOPY, ddbclassname(class),ename); msgn++; } } } void copysheet(string sfn,string dfn,string sheetname,int merge) /* // Copy schematic sheet with name conflict resolving // Return value : // zero if done or (-1) on copy error // Parameters : // string sfn : Source file name // string dfn : Destination file name // string sheetname : Schematic sheet name // int merge : Merge flag */ { STRINGS projectrulel /* Project rule list */; int projectrulen /* Project rule count */; STRINGS planrulel /* Plan rule list */; int planrulen /* Plan rule count */; double wslx, wsly /* Workspace lower boundary */; double wsux, wsuy /* Workspace upper boundary */; double wsnx, wsny /* Workspace origin */; double ex, ey /* Coordinate extrema */; int rangedis /* Range check disabled flag */; // Test if destination element exists already if (ddbcheck(dfn,DDBCLSCM,sheetname)==0) { if (!merge) return; verifysave(); bae_loadelem(sfn,sheetname,DDBCLSCM); wslx=bae_planwslx(); wsly=bae_planwsly(); wsux=bae_planwsux(); wsuy=bae_planwsuy(); wsnx=bae_planwsnx(); wsny=bae_planwsny(); // Select group ulsystem("scmgroup:sl0:sl0",0); // Store group to clipboard bae_setintpar(22,1); bae_callmenu(MNU_BAEGRPCOPY); bae_setintpar(22,0); // Get the plan and object rules projectrulen=getplanrules(projectrulel,1); planrulen=getplanrules(planrulel,0); // Close current element bae_clriactqueue(); if (bae_plannotsaved()) bae_storetextiact(1,M_UINYES()); bae_callmenu(MNU_BAECLOSE); // Load element loadddbelem(dfn,sheetname,DDBCLSCM); // Select group ulsystem("scmgroup:sl0:sl0",0); // Delete group bae_callmenu(MNU_SCMDELGRP); } else { verifysave(); bae_loadelem(sfn,sheetname,DDBCLSCM); wslx=bae_planwslx(); wsly=bae_planwsly(); wsux=bae_planwsux(); wsuy=bae_planwsuy(); wsnx=bae_planwsnx(); wsny=bae_planwsny(); // Select group ulsystem("scmgroup:sl0:sl0",0); // Store group to clipboard bae_setintpar(22,1); bae_callmenu(MNU_BAEGRPCOPY); bae_setintpar(22,0); // Get the plan and object rules projectrulen=getplanrules(projectrulel,1); planrulen=getplanrules(planrulel,0); // Close current element bae_clriactqueue(); if (bae_plannotsaved()) bae_storetextiact(1,M_UINYES()); bae_callmenu(MNU_BAECLOSE); bae_clriactqueue(); bae_storemenuiact(1,0,LMB); bae_storetextiact(1,dfn); bae_storetextiact(1,sheetname); bae_storemenuiact(1,14,LMB); bae_storetextiact(1,"1"); bae_storetextiact(1,"1"); bae_setintpar(22,1); call(MNU_SCMCREELEM); bae_setintpar(22,0); } // Disable range check bae_getintpar(0,rangedis); bae_setintpar(0,1); // Set lower element boundary bae_clriactqueue(); ex=wslx+wsnx; if (bae_planwslx()ex) ex=bae_planwsux(); if (wsnx>ex) ex=wsnx; ey=wsuy+wsny; if (bae_planwsuy()>ey) ey=bae_planwsuy(); if (wsny>ey) ey=wsny; bae_storemouseiact(1,ex,ey,2,LMB); bae_callmenu(MNU_SCMPARUBND); // Set element origin bae_storemouseiact(1,wsnx,wsny,2,LMB); bae_callmenu(MNU_SCMPARORIG); // Set lower element boundary bae_storemouseiact(1,wslx,wsly,2,LMB); bae_callmenu(MNU_SCMPARLBND); // Set upper element boundary bae_storemouseiact(1,wsux,wsuy,2,LMB); bae_callmenu(MNU_SCMPARUBND); bae_setintpar(22,2); call(MNU_BAEZOOMALL); bae_setintpar(22,0); // Paste clipboard group bae_clriactqueue(); bae_storemouseiact(1,bae_planwsnx(),bae_planwsny(),2,LMB); bae_setintpar(22,1); bae_callmenu(MNU_BAEGRPPASTE); bae_setintpar(22,0); call(MNU_SCMGRPRESE); /* Load the parameter set */ bae_clriactqueue(); bae_storetextiact(1,sfn); bae_callmenu(MNU_BAELOADPAR); // Attach/detach the rule lists if (projectrulen) cap_ruleplanatt(projectrulel,1); else if (cap_getrulecnt(3,0)>0) cap_ruleplandet(1); if (planrulen) cap_ruleplanatt(planrulel,0); else if (cap_getrulecnt(0,0)>0) cap_ruleplandet(0); // Restore old range check state bae_setintpar(0,rangedis); bae_setintpar(22,1); call(MNU_GEDSAVELEM); bae_setintpar(22,0); } int getplanrules(STRINGS rl,int project) /* // Get rules attached to current plan // Return value : // rule count // Parameters : // STRINGS rl : Rule name list // int project : Global project rule flag */ { STRINGS sl = {""}; // Initialyzed string list int rc; // Rule count int i; // Loop control variables // Get the rule count if ((rc=cap_getrulecnt(project ? 3 : 0,0))<0) return(0); // Get and store the rule names for (rl=sl,i=0;i