/* SAVEELAS (STD) -- Save Element As */ /* SAVEELAS (STD) -- Ablegen auf Namen */ /* // Copyright (c) 1995-2012 Oliver Bartels F+E, Muenchen // Author: Manfred Baumeister // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (111215) CHANGE: // Now prompting for current sheet save before group functions // instead of automatic save. // rl (101019) RELEASED FOR BAE V7.6. // rl (100923) ENHANCEMENT: // Added file and class name to destination name selection prompt. // rl (091021) RELEASED FOR BAE V7.4. // rl (090127) ENHANCEMENT: // Added symbol name conflict handling for schematic save // to different file. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (060829) RELEASED FOR BAE V6.8. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (030904) RELEASED FOR BAE V6.2. // rl (021209) RELEASED FOR BAE V6.0. // rl (021203) ENHANCEMENT: // Added automatic load of saved element option. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (000509) RELEASED FOR BAE V4.6. // rl (990713) RELEASED FOR BAE V4.4. // rl (990302) ENHANCEMENT: // Added current element name proposing. // rl (980910) RELEASED FOR BAE V4.2. // mb (980710) ENHANCEMENT: // Dynamic multi-language support introduced. // rl (970929) RELEASED FOR BAE V4.0. // mb (960919) RELEASED FOR BAE V3.4. // mb (95) RELEASED FOR BAE V3.2. // mb (950124) ORIGINAL CODING. // // DESCRIPTION // // The saveelas User Language program stores the currently // loaded element with a freely selectable file and element // name. Overwrite verification is automatically activated // on existing destination elements. */ // Includes #include "pop.ulh" // User Language popup utilities // Enforce editor caller type #pragma ULCALLEREDT // Disable undo state request #pragma ULCALLERNOUNDO // Messages string REPSAVED = M("Aktuell geladenes Element gesichert in '%s' '%s'.", "Currently loaded element saved to '%s' '%s'."); string UPRDFILE = M("!Ziel-Dateiname ? ","!Destination File Name ? "); string UPRDELEM = M("Ziel-%sname in '%s' ? ", "Destination %s Name in '%s' ? "); string UPRLIBUPD = M("Bibliothekselemente mitkopieren ? ", "Copy Library Elements ? "); string UPRREPLC = M("%s '%s' in '%s' ueberschreiben ? ", "Overwrite %s '%s' in '%s' ? "); string UPRLOGCOPY = M("Logische Bibliothek gefunden. Mitkopieren ?", "Logical Library found. Copy ?"); string UPRSAVE1 = M("Zielblatt wird mit Gruppenfunktionen erzeugt. ", "Destination sheet will be created with group functions. "); string UPRSAVE2 = M("Aenderungen am aktuellen Blatt '%s' vorher in '%s' sichern ?", "Save changes of current sheet '%s' to '%s' as well?"); string ERRSAVED = M("Aktuell geladenes Element ist bereits gesichert!", "Currently loaded element already saved!"); string ERRSAVEC = M("Fehler beim Sichern des aktuellen Elementes!", "Error saving current element!"); string ERRSAVEF = M("Fehler beim Sichern des aktuellen Elements auf '%s' '%s'!", "Error saving currently loaded element to '%s' '%s'!"); // INI file parameter name definitions #define PAR_SAVEASLOAD "SAVEASLOAD_STD" // Auto. load after save as #define PAR_SAVEASLIBUPD "SAVEASLIBUPD_STD" // Library update mode int LIBUPD = bae_iniintval(PAR_SAVEASLIBUPD,1) /* Library update mode */; static int WINDOWS = bae_swconfig(3)==BAE_WinStd || bae_swconfig(3)==BAE_WinPulldwn /* BAE Windows software flag */; #define BAKEXT ".bak" // Backup file extension // Main program void main() { index C_NREF nref /* Named reference index */; index C_MACRO macro /* Macro index */; string cfname = bae_planfname() /* Current job file name */; string cename = bae_planename() /* Current job element name */; string fname /* Destination file name */; string ename /* Destination element name */; string bname = "" /* Backup file name */; string strbuf /* String buffer */; string ecomment /* Element comment buffer */; STRINGS projectrulel /* Project rule list */; int projectrulen /* Project rule count */; STRINGS planrulel /* Plan rule list */; int planrulen /* Plan rule count */; double wslx = bae_planwslx() /* Workspace left boundary */; double wsly = bae_planwsly() /* Workspace bottom boundary */; double wsux = bae_planwsux() /* Workspace right boundary */; double wsuy = bae_planwsuy() /* Workspace top boundary */; double wsnx = bae_planwsnx() /* Workspace x origin coordinate */; double wsny = bae_planwsny() /* Workspace y origin coordinate */; double ex, ey /* Coordinate extrema */; int rangedis /* Range check disabled flag */; int nconflict = 0 /* Name conflict flag */; int loglflag = (-1) /* Loglib flag */; int ddbcl = bae_planddbclass() /* DDB element class */; // Abort if invalid plan class if (ddbcl==DDBCLUNDEF) error_class(); // Select the destination file and element name ename=cename; if (bae_askddbfname(fname,0,UPRDFILE)) // Abort error_abort(); if (bae_askddbename(ename,fname,ddbcl, msg2string(UPRDELEM,ddbclassname(ddbcl),convstring(fname,1)))) // Abort error_abort(); // Check if schematic storage to different non empty file if (ddbcl==DDBCLSCM) { if (fname!=cfname && scanddbenames(fname,DDBCLSCM,bname)==1) { // Flush scan cache scanddbenames(fname,0,""); // Scan for name conflict forall (nref where nref.MACRO.CLASS==DDBCLSSYM) if (ddbcheck(fname,DDBCLSPLST,nref.NAME)==0) { nconflict=1; break; } } else if (fname==cfname) { forall (nref where nref.MACRO.CLASS==DDBCLSSYM) { nconflict=1; break; } } } // Check if different file name conflict if (nconflict) { // Build the message string sprintf(strbuf,UPRSAVE1+UPRSAVE2,cename,cfname); // Save current element on request if (bae_plannotsaved() && verify(strbuf,1) && bae_storeelem(bae_planfname(),bae_planename())<0) // Save error error(ERRSAVEC); // Get the element comment bae_getstrpar(0,ecomment); // Test if destination element exists already if (ddbcheck(fname,ddbcl,ename)==0) { // Build prompt string sprintf(strbuf,UPRREPLC, ddbclassname(ddbcl),ename,fname); // Verify on destination element overwrite if (!verify(strbuf,0)) error_abort(); bname=convstring(fname,0)+BAKEXT; // Copy element to backup file, ignore errors ddbcopyelem(fname,bname,ddbcl,ename,1); // 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_UINNO()); bae_callmenu(MNU_BAECLOSE); // Load element loadddbelem(fname,ename,ddbcl); // Select group ulsystem("scmgroup:sl0:sl0",0); // Delete group bae_callmenu(MNU_SCMDELGRP); } else { // 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_UINNO()); bae_callmenu(MNU_BAECLOSE); bae_clriactqueue(); bae_storemenuiact(1,0,LMB); bae_storetextiact(1,fname); bae_storetextiact(1,ename); 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); call(MNU_BAEZOOMALL); // 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,cfname); 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); // Set the element comment bae_setstrpar(0,ecomment); // Restore old range check state bae_setintpar(0,rangedis); bae_setintpar(22,1); call(MNU_SCMSAVELEM); bae_setintpar(22,0); // Check if automatic load requested if (!bae_iniintval(PAR_SAVEASLOAD,0)) loadddbelem(cfname,cename,ddbcl); if (cfname!=fname) forall (macro where macro.CLASS==DDBCLSSYM) { if (loglflag==(-1) && existddbelem(cfname,DDBCLLLIB,macro.NAME)==1) loglflag= bae_msgboxverify(UPRLOGCOPY,"")==1 ? 1 : 0 ; // Do extra logical library copy on request if (loglflag==1) ddbcopyelem( cfname,fname,DDBCLLLIB,macro.NAME,1); } exit(0); } // Test if selected element is currently loaded if (fname==cfname && ename==cename && ddbcheck(fname,ddbcl,ename)==0) { // Abort if element already saved if (!bae_plannotsaved()) error(ERRSAVED); } else { // Test if destination element exists already if (ddbcheck(fname,ddbcl,ename)==0) { // Build prompt string sprintf(strbuf,UPRREPLC, ddbclassname(ddbcl),ename,fname); // Verify on destination element overwrite if (!verify(strbuf,0)) error_abort(); bname=convstring(fname,0)+BAKEXT; // Copy element to backup file, ignore errors ddbcopyelem(fname,bname,ddbcl,ename,1); } } if (ddbcl==DDBCLSCM && cfname!=fname) forall (macro where macro.CLASS==DDBCLSSYM || macro.CLASS==DDBCLSLAB) { if (loglflag==(-1) && existddbelem(cfname,DDBCLLLIB,macro.NAME)==1) loglflag= bae_msgboxverify(UPRLOGCOPY,"")==1 ? 1 : 0 ; // Do extra logical library copy on request if (loglflag==1) ddbcopyelem( cfname,fname,DDBCLLLIB,macro.NAME,1); } // Save currently loaded element if (bae_storeelem(fname,ename)) { // Assume file access error sprintf(strbuf,ERRSAVEF,ename,fname); } else { if (fname!=bae_planfname() && (!WINDOWS || namestrcmp(fname,bae_planfname())!=0) && ddbcl!=DDBCLSMRK && ddbcl!=DDBCLLPAD && ddbcl!=DDBCLIPIN) { // Verify on destination element overwrite if (LIBUPD==2 || (LIBUPD==1 && verify(UPRLIBUPD,0))) { /* Update library */ bae_clriactqueue(); switch (ddbcl) { case DDBCLSLAB : case DDBCLLSTK : bae_storemenuiact(1,2,LMB); break; case DDBCLSSYM : case DDBCLLPRT : case DDBCLICELL : bae_storemenuiact(1,1,LMB); break; case DDBCLSCM : case DDBCLLAY : case DDBCLILAY : default : bae_storemenuiact(1,0,LMB); } bae_storetextiact(1,fname); bae_storetextiact(1,ename); bae_storetextiact(1,bae_planfname()); bae_callmenu(206); } } // Done sprintf(strbuf,REPSAVED,ename,fname); // Check if automatic load requested if (bae_iniintval(PAR_SAVEASLOAD,0)) loadddbelem(fname,ename,ddbcl); } bae_prtdialog(strbuf); } 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