/* GINSOUT (CAM) -- Generic Insertion Data Output */ /* GINSOUT (CAM) -- Frei konfigurierbare Bestueckdatenausgabe */ /* // Copyright (c) 1999-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 (100324) ENHANCEMENT: // Added automatic path creation for fix output file specification. // Added placement status independant part output option. // rl (091021) RELEASED FOR BAE V7.4. // rl (090213) ENHANCEMENT: // Added name and attribute value upper case conversion options. // rl (081014) RELEASED FOR BAE V7.2. // rl (080702) ENHANCEMENT: // Added centered/logical text warnings. // rl (080226) ENHANCEMENT: // Added alternate output layer support. // rl (080124) BUGFIX: // Fixed problem with origin at part pick point output. // rl (071029) RELEASED FOR BAE V7.0. // rl (071025) ENHANCEMENT: // Added variant output loop option. // Extended alternate attribute list length to 4. // Added absolute path recognition for INSSUBDIR_CAM. // rl (071010) ENHANCEMENT: // Allowed negative conversion factors for coordinate mirroring. // rl (070627) ENHANCEMENT: // Added part pick coordinate output option. // rl (060829) RELEASED FOR BAE V6.8. // rl (060712) ENHANCEMENT: // Added variant and attribute header and file name options. // rl (060321) ENHANCEMENT: // Added angle transformation options. // rl (060303) ENHANCEMENT: // Added origin definition commands. // rl (050906) RELEASED FOR BAE V6.6. // rl (040811) RELEASED FOR BAE V6.4. // rl (040514) ENHANCEMENT: // Added group name specific output support. // Added group name exclusion list support for output. // rl (030904) RELEASED FOR BAE V6.2. // rl (030707) ENHANCEMENT: // Added alternate attribute option to format description. // rl (030128) ENHANCEMENT: // Added layer and file name options to format description. // Added optional suppressing of empty output files. // Added optional scan of format description directory. // Added tabulator output option. // rl (021209) RELEASED FOR BAE V6.0. // rl (020618) RELEASED FOR BAE V5.4. // rl (010625) RELEASED FOR BAE V5.0. // rl (000509) RELEASED FOR BAE V4.6. // rl (000202) CHANGE: // Changed environment to CAM-Processor. Added use of CAM origin. // Disabled output of pin texts. // rl (990813) RELEASED FOR BAE V4.4. // rl (990622) ORIGINAL CODING. // // DESCRIPTION // // The ginsout User Language program provides generic insertion data // output. The output format is specified in an external script file. */ // Includes #include "pop.ulh" // User Language popup utilities #include "sql.ulh" // User Language SQL utilities #include "lay.ulh" // User Language layout utilities // Messages string REPDIREXT = M("Dateiverzeichnis '%s' / Extension '%s' :", "Directory '%s' / Extension '%s' :"); string REPDIRINV = M("-- Ungueltiger Verzeichnisname! --", "-- Invalid Directory Path Name! --"); string REPDIRINC = M("-- Auflistung abgebrochen/unvollstaendig! --", "-- Listing aborted/incomplete! --"); string REPSTART = M("Schreiben Bestueckdaten...", "Writing insertion file..."); string REPGRPNSCAN = M("Scannen Gruppennamen...", "Scanning group names..."); string REPGNAMELIST = M("Auswahl Gruppenname :","Group Name Selection :"); string REPDONE = M("Datei '%s' ausgegeben.", "File output '%s' done."); string REPNDONE = M("%d Bestueckdatendateien ausgegeben.", "%d insertion data files written."); string REPGINFILE = M(" Bestueckdaten Datei : '%s'", " Insertion Data File : '%s'"); string UPRDOCLAY = M("Bestueckdaten Ausgabelage waehlen!", "Select Insertion Data Output Layer"); string UPRINSFILE = M("!Bestueckdaten Ausgabedatei ? ", "!Insertion Data Output File ? "); string UPRISFFILE = M("Formatbeschreibungsdatei ? ", "Format Description File ? "); string UPRSELGNAME = M("Gruppenname fuer die Ausgabe ? ", "Group name to output ? "); string WRNCENTTEXT1 = M("WARNUNG: %d zentrierte %s (z.B. '%s')!", "WARNING: %d centered %s (e.g. '%s')!"); string WRNCENTTEXT2 = M("Texte wegen Verschiebung als Pickpunkt ungeeignet", "texts not suitable for pick point"); string WRNLOGTEXT1 = M("WARNUNG: %d verschiebbare %s (z.B. '%s')!", "WARNING: %d moveable %s (e.g. '%s')!"); string WRNLOGTEXT2 = M("Texte mit Modus LOGICAL evtl. als Pickpunkt ungeeignet", "texts with mode LOGICAL may be not suitable for pick point"); string ERRFOPEN = M("Fehler beim Oeffnen der Ausgabedatei '%s'!", "Error opening output file '%s'!"); string ERRNOGRPNAMES = M("Keine Bauteile mit Gruppennamen!", "No parts with group name attached found!"); // INI file parameter name definitions #define PAR_IFSFEXT "IFSFEXT_CAM" // Insertion spec. file name ext. #define PAR_IFSFDIR "IFSFDIR_CAM" // Insertion spec. file directory #define PAR_INSSUBDIR "INSSUBDIR_CAM" // Insertion file output directory // File transfer definitions string IFSEXT = bae_inistrval(PAR_IFSFEXT,".ifs"); // Insertion format spec. file ext. string IFSDIR = bae_inistrval(PAR_IFSFDIR,""); // Insertion format spec. file dir. string INSSUBDIR = bae_inistrval(PAR_INSSUBDIR,""); // Insertion data output file dir. STRINGS extlist = { // Insertion spec. file extensions IFSEXT }; #define GV_INSFORMAT "GIN_FORMAT" // Remote control operation format name #define GV_BATCALL "BAT_CALL" // Remote control operation flag #define GV_BATREPCNT "BAT_REPCNT" // Remote control op. report count #define GV_BATREPLINE "BAT_REPL_" // Remote control op. report line #define MAXLINELEN 1024 // Maximum input line length #define ORGREF "!" // Origin reference string // Field type definitions #define F_NAME 0 #define F_MACRO 1 #define F_ATTR 2 #define F_XCOORD 3 #define F_YCOORD 4 #define F_ANGLE 5 #define F_MIRR 6 #define F_COUNT 7 #define F_NATTR 8 #define F_SEP 9 #define F_TAB 10 #define F_QATTR 11 struct fielddesc { // Output field descriptor int typ /* Output field type */; int align /* Output field alignment */; int casemode /* Output field case conv. mode */; int len /* Output field total length */; int frac /* Output field fraction digits */; double conv /* Output field conversion factor */; string spec /* Output field name spec. */; string spec2 /* Output field 2nd name spec. */; string spec3 /* Output field 3rd name spec. */; string spec4 /* Output field 4th name spec. */; string empty /* Output field empty string */; } fieldl[] /* Output field list */; int fieldn = 0 /* Output field count */; struct linedesc { /* Line descriptor */ string linetext /* Line text string */; string ml[] /* Macro name list */; string n1l[] /* 1st name list */; string n2l[] /* 2nd name list */; string n3l[] /* 3rd name list */; string n4l[] /* 4th name list */; string dnl[] /* Default name list */; int ntl[] /* Name type list */; }; struct linedesc headl[] /* Header line list */; int headn = 0 /* Header line list count */; struct linedesc traill[] /* Header line list */; int trailn = 0 /* Header line list count */; STRINGS grpexcll /* Group exclude name list */; int grpexcln = 0 /* Group exclude name list count */; string grpname = "" /* Group name */; struct laydesc { // Output layer descriptor int layer /* Output layer */; int layer2 /* Output 2nd layer */; int angmode /* Output angle mode */; int ftyp /* Output file name type */; int partset /* Output part set */; int textflag /* Output text scan flag */; string comm /* Output file name comment */; string file /* Output file name spec. */; string fsep /* Output file name seperator */; string origsym /* Output origin symbol name */; string macname /* Output macro name */; string name1 /* Output 1st name */; string name2 /* Output 2nd name */; string name3 /* Output 3rd name */; string name4 /* Output 4th name */; string defname /* Output default name */; } layl[] /* Output layer list */; int layn = 0 /* Output layer count */; int noempty = 0 /* No empty file output flag */; int partset = 0 /* Part set */; int textscan = 0 /* Text scan flag */; // Globals int fh /* Insertion data file handle */; int outlayer /* Insertion data output layer */; int outlayer2 /* Insertion data output 2nd layer */; int outangmode /* Insertion data output angle mode */; int tcnt /* Total output element count */; int ccnt /* Current output element count */; string curmacname /* Current macro name */; string curcomment /* Current comment */; string curstr /* Current string */; string curname1 /* Current 1st name */; string curname2 /* Current 2nd name */; string curname3 /* Current 3rd name */; string curname4 /* Current 4th name */; string curdefname /* Current default name */; string curfsep /* Current file name seperator */; int tccnt /* Text centered count */; string tctext /* Text centered sample */; int tlcnt /* Text logical count */; string tltext /* Text logical sample */; int curnidx /* Current name index */; int curhead /* Current head line proc. flag */; int curmirr /* Current mirror mode */; int year,mon,day /* Date */; int hour,min,sec /* Time buffers */; index L_CPART cpart /* Connection part list index */; index L_FIGURE fig /* Figure list index */; int cpartflag /* Connection part known flag */; int textflag /* Text scan flag */; int remoteflag = 0 /* Remote control operation flag */; int remotecnt = 0 /* Remote control op. file count */; double DPI = cvtangle(360.0,1,2) /* Double PI value */; double PI = cvtangle(180.0,1,2) /* PI value */; // SQL command definitions #define V_SELECT "select variant,name from varinfo;" STRINGS varnames /* Variant names */; int curvar /* Current variant index */; int varn = 0 /* Variant count */; // Main program void main() { string isfname /* ISF file name */; string fname /* Output file name */; string fnamebase /* Job name base */; string fnamedir /* Job name directory */; string sfname /* Short job file name */; string dirsep="/" /* Directory separator */; string dirbuf /* Directory name buffer */; string attval /* Attribute value */; string msg /* Message string */; int abspath /* Absolute directory spec. flag */; STRINGS hl /* Header string list */; int hn = 2 /* Header string count */; STRINGS el /* Entry string list */; int en /* Entry string count */; int popcols /* Requested popup columns */; int lastvar /* Last variant number */; int i /* Loop variable */; // Abort if invalid plan class if (bae_planddbclass()!=DDBCLLAY) error_class(); // Perform BAE Demo check with abort option BAE_Demo_check(2); // Get file name bases fname=bae_planfname(); if (INSSUBDIR[0]=='*') INSSUBDIR=convstring(fname,2)+ strextract(INSSUBDIR,1,strlen(INSSUBDIR)-1); sfname=fnamebase=fname=convstring(fname,0); fnamedir=""; for (i=strlen(fname)-1;i>=0;i--) if (fname[i]=='/' || fname[i]=='\\' || fname[i]==':') { if (fname[i]!=':') dirsep[0]=fname[i]; // Delimiter found fnamedir=fname; fnamedir[i+1]='\0'; sfname=strextract(fname,i+1,strlen(fname)); break; } abspath= (INSSUBDIR=="" || (INSSUBDIR[0]!='\\' && INSSUBDIR[0]!='/' && INSSUBDIR[0]!='$' && (strlen(INSSUBDIR)<2 || INSSUBDIR[1]!=':'))) ? 0 : 1 ; // Check if remote control operation if (varget(GV_BATCALL,remoteflag)==0) remoteflag=1; // Check if remote control operation with format selection if (varget(GV_INSFORMAT,isfname)==0) { vardelete(GV_INSFORMAT); remoteflag=1; if (IFSDIR!="") isfname=IFSDIR+dirsep+isfname; } // Check if special format description directory defined else if (IFSDIR!="") { // Init the header list hl[hn-1]=""; // Report the directory list header sprintf(hl[0],REPDIREXT,IFSDIR,IFSEXT); // Clear the file name entry list en=0; // Build the file name list (with abort enabled) switch (filelist(el,en,IFSDIR,IFSEXT,"",0,0,0,0,1,1)) { // Invalid directory path name case (-1) : el[en++]=REPDIRINV; break; // Directory listing aborted case 1 : el[en++]=REPDIRINC; break; } // Show the file menu with select disabled bae_setintpar(16,3014); if ((isfname=popupmenu(4,"",hl,hn,el,en,UINPOPABORT, 0,0,-1,hn+en+2,100,0,UINPOPABORT))=="" || isfname==UINPOPABORT) error_abort(); isfname=IFSDIR+dirsep+isfname; } else { // Select the insertion format spec. input file if ((isfname=askfile(UPRISFFILE,extlist,0))=="") error_abort(); } // Parse the insertion format spec. file parsefile(isfname); // Get date get_date(day,mon,year); get_time(hour,min,sec); // Build the variant number string sqlcmd(bae_planfname(),V_SELECT,varfunc); // Query the current active variant if (lay_rulequery(RS_OCPLAN,0,RS_PCBSUBJ,RS_VARIANT,"?d",curvar)<1) // Use base variant curvar=0; // Check if group name query request if (grpname==UINPOPABORT) { // Scan group names bae_prtdialog(REPGRPNSCAN); en=0; forall (fig where (fig.TYP==L_FIGNREF || fig.TYP==L_FIGTEXT) && fig.RULEOBJID>=0) { // Query group name predicate if (lay_rulequery(RS_OCFIG,fig,RS_PCBSUBJ,RS_GROUPNAME, "?s",grpname)<1) continue; // Check if already defined for (i=0;i=en) { // Store new name el[en]=grpname; en++; } } // Check if group names found if (en==0) error(ERRNOGRPNAMES); // Build the group name menu hl[0]=REPGNAMELIST; hn=2; popcols=strlen(hl[0])+1; // Select group name nets bae_setintpar(16,3015); if ((grpname=popupmenu(1,UPRSELGNAME, hl,hn,el,en,UINPOPABORT,0,1,1,hn+en+2,popcols,0,""))=="" || grpname==UINPOPABORT) // Aborted error_abort(); } // Check if layers defined if (layn==0) { // Get output documentary layer if (bae_prtdialog(UPRDOCLAY),cam_askplotlayer(outlayer)) error_abort(); // Get the insertion data file name if (bae_askfilename(fname,"-",UPRINSFILE) || fname=="") error_abort(); // Write output file bae_prtdialog(REPSTART); writelayer(fname,"",outlayer,outlayer,0); } else { // Check if subdirectory requested if (INSSUBDIR!="") { if (abspath) { fname=INSSUBDIR; } else { fname=fnamedir!="" ? fnamedir : ""; fname+=INSSUBDIR; } if (filetype(fname)!=0) bae_createdir(fname); } // Write output files bae_prtdialog(REPSTART); for (i=0;i1) sprintf(msg,REPNDONE,layn); else sprintf(msg,REPDONE,strgetvarfilename(fname)); // Done bae_prtdialog(msg); } } void writelayer(string fname,string origsym,int layer,int layer2,int angmode) /* // Write insertion data for given layer // Parameters : // string fname : Output file name // string origsym : Output origin symbol name // int layer : Insertion layer // int layer2 : 2nd insertion layer // int angmode : Angle mode */ { string msg /* Message string */; string gname /* Group name */; string tstr /* Text string */; double nx,ny /* Origin coordinates */; int i /* Loop control variable */; // Set output layer outlayer=layer; outlayer2=layer2; outangmode=angmode; tccnt=tlcnt=0; if (noempty) { // Count texts on output layer tcnt=0; forall (fig where fig.TYP==L_FIGNREF || (textscan && fig.TYP==L_FIGTEXT)) { // Query group name predicate if (fig.RULEOBJID<0 || lay_rulequery(RS_OCFIG,fig, RS_PCBSUBJ,RS_GROUPNAME,"?s",gname)<1) gname=""; // Check if desired group name if (grpname!="" && grpname!=gname) continue; // Check if excluded group name for (i=0;i=DPI) pangle-=DPI; // Output all fields for (i=0;i=arylength(ERRS)) sprintf(msg,ERRS[arylength(ERRS)-1],status); else sprintf(msg,ERRS[status],fn,synscanline(),synscanstring()); // Print the error message error(msg); } // Parser action routines int p_headline() /* // Handle the header line store request // Return value : // zero if done or (-1) on error */ { headl[headn].linetext=curstr; headl[headn].ntl[0]=headl[headn].ntl[1]=headl[headn].ntl[2]=(-1); headl[headn].ntl[3]=headl[headn].ntl[4]=(-1); headn++; curhead=1; curnidx=0; // Return without errors return(0); } int p_trailline() /* // Handle the trailer line store request // Return value : // zero if done or (-1) on error */ { traill[trailn].linetext=curstr; traill[trailn].ntl[0]=traill[trailn].ntl[1]=traill[trailn].ntl[2]=(-1); traill[trailn].ntl[3]=traill[trailn].ntl[4]=(-1); trailn++; curhead=0; curnidx=0; // Return without errors return(0); } int p_align(int align) /* // Handle the alignment store request // Return value : // zero if done or (-1) on error // Parameters : // int align : Alignment code */ { fieldl[fieldn].align=align; fieldl[fieldn].casemode=0; // Return without errors return(0); } int p_case(int casemode) /* // Handle the case conversion mode store request // Return value : // zero if done or (-1) on error // Parameters : // int align : Alignment code */ { fieldl[fieldn].casemode=casemode; // Return without errors return(0); } int p_field(int typ) /* // Handle the field type store request // Return value : // zero if done or (-1) on error // Parameters : // int typ : Field type */ { fieldl[fieldn].typ=typ; fieldn++; fieldl[fieldn].len=fieldl[fieldn].frac=0; fieldl[fieldn].conv=1.0; fieldl[fieldn].empty=""; // Return without errors return(0); } int p_spec() /* // Handle the spec. string store request // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].spec=fieldl[fieldn].spec2= fieldl[fieldn].spec3=fieldl[fieldn].spec4=curstr; // Return without errors return(0); } int p_spec2() /* // Handle the second spec. string store request // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].spec2=curstr; // Return without errors return(0); } int p_spec3() /* // Handle the third spec. string store request // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].spec3=curstr; // Return without errors return(0); } int p_spec4() /* // Handle the forth spec. string store request // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].spec4=curstr; // Return without errors return(0); } int p_empty() /* // Handle the empty field string store request // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].empty=curstr; // Return without errors return(0); } int p_noempty() /* // Handle the no empty file flag request // Return value : // zero if done or (-1) on error */ { noempty=1; // Return without errors return(0); } int p_groupexclude() /* // Handle the group exclude store request // Return value : // zero if done or (-1) on error */ { grpexcll[grpexcln]=curstr; grpexcln++; // Return without errors return(0); } int p_groupname() /* // Handle the group name store request // Return value : // zero if done or (-1) on error */ { grpname=curstr; // Return without errors return(0); } int p_string() /* // Handle the string store request // Return value : // zero if done or (-1) on error */ { curstr=synscanstring(); // Return without errors return(0); } int p_fsep() /* // Handle the file name seperator store request // Return value : // zero if done or (-1) on error */ { curfsep=curstr; // Return without errors return(0); } int p_macname() /* // Handle the macro name store request // Return value : // zero if done or (-1) on error */ { curmacname=curstr; strlower(curmacname); // Return without errors return(0); } int p_name1() /* // Handle the 1st name store request // Return value : // zero if done or (-1) on error */ { curname1=curname2=curname3=curname4=curstr; // Return without errors return(0); } int p_name2() /* // Handle the 2nd name store request // Return value : // zero if done or (-1) on error */ { curname2=curstr; // Return without errors return(0); } int p_name3() /* // Handle the 3rd name store request // Return value : // zero if done or (-1) on error */ { curname3=curstr; // Return without errors return(0); } int p_name4() /* // Handle the 4th name store request // Return value : // zero if done or (-1) on error */ { curname4=curstr; // Return without errors return(0); } int p_defname() /* // Handle the default name store request // Return value : // zero if done or (-1) on error */ { curdefname=curstr; // Return without errors return(0); } int p_groupquery() /* // Handle the group name query store request // Return value : // zero if done or (-1) on error */ { grpname=UINPOPABORT; // Return without errors return(0); } int p_initoutput(int txtflag) /* // Receive an output data init. request // Return value : // zero if done or (-1) on error // Parameter : // int txtflag : Text scan flag */ { layl[layn].angmode=0; layl[layn].comm=""; layl[layn].origsym=""; layl[layn].layer=(-1); layl[layn].textflag=txtflag; layl[layn].partset=0; curname1=curname2=curname3=curname4=""; curmacname=""; curfsep=""; // Return without errors return(0); } int p_angmode(int mode) /* // Receive an angle mode specification // Return value : // zero if done or (-1) on error // Parameter : // int mode : Angle mode */ { layl[layn].angmode=mode; // Return without errors return(0); } int p_layer() /* // Receive a layer specification // Return value : // zero if done or (-1) on error */ { layl[layn].layer=atoi(synscanstring()); layl[layn].layer2=layl[layn].layer; // Return without errors return(0); } int p_doclayer() /* // Handle the documentary layer specification // Return value : // zero if done or (-1) on error */ { layl[layn].layer=1024+16*(atoi(synscanstring())-1); layl[layn].layer2=layl[layn].layer; // Return without errors return(0); } int p_docside() /* // Handle the documentary layer side specification // Return value : // zero if done or (-1) on error */ { layl[layn].layer|=atoi(synscanstring())-1; layl[layn].layer2=layl[layn].layer; // Return without errors return(0); } int p_layer2() /* // Receive a 2nd layer specification // Return value : // zero if done or (-1) on error */ { layl[layn].layer2=atoi(synscanstring()); // Return without errors return(0); } int p_doclayer2() /* // Handle the documentary 2nd layer specification // Return value : // zero if done or (-1) on error */ { layl[layn].layer2=1024+16*(atoi(synscanstring())-1); // Return without errors return(0); } int p_docside2() /* // Handle the documentary 2nd layer side specification // Return value : // zero if done or (-1) on error */ { layl[layn].layer2|=atoi(synscanstring())-1; // Return without errors return(0); } int p_filetyp(int typ) /* // Handle the file type store request // Return value : // zero if done or (-1) on error // Parameter : // int typ : File type code */ { layl[layn].ftyp=typ; layl[layn].fsep=curfsep; layl[layn].macname=curmacname; layl[layn].name1=curname1; layl[layn].name2=curname2; layl[layn].name3=curname3; layl[layn].name4=curname4; layl[layn].defname=curdefname; // Return without errors return(0); } int p_pattr(int typ) /* // Handle the attribute type store request // Return value : // zero if done or (-1) on error // Parameter : // int typ : Attribute type code */ { if (curhead) { headl[headn-1].ml[curnidx]=curmacname; headl[headn-1].n1l[curnidx]=curname1; headl[headn-1].n2l[curnidx]=curname2; headl[headn-1].n3l[curnidx]=curname3; headl[headn-1].n4l[curnidx]=curname4; headl[headn-1].dnl[curnidx]=curdefname; headl[headn-1].ntl[curnidx]=typ; } else { traill[trailn-1].ml[curnidx]=curmacname; traill[trailn-1].n1l[curnidx]=curname1; traill[trailn-1].n2l[curnidx]=curname2; traill[trailn-1].n3l[curnidx]=curname3; traill[trailn-1].n4l[curnidx]=curname4; traill[trailn-1].dnl[curnidx]=curdefname; traill[trailn-1].ntl[curnidx]=typ; } curnidx++; // Return without errors return(0); } int p_fileext() /* // Handle the file extension store request // Return value : // zero if done or (-1) on error */ { layl[layn].file=curstr; layn++; // Return without errors return(0); } int p_origsym(int planorig) /* // Handle the output origin symbol name // Parameters : // int planorig : Plan origin reference // Return value : // zero if done or (-1) on error */ { if (layn>0) { layl[layn-1].origsym=planorig ? ORGREF : curstr; strlower(layl[layn-1].origsym); } // Return without errors return(0); } int p_laycomment() /* // Handle the layer comment // Return value : // zero if done or (-1) on error */ { if (layn>0) layl[layn-1].comm=curstr; // Return without errors return(0); } int p_laypartall() /* // Handle the layer all parts flag // Return value : // zero if done or (-1) on error */ { if (layn>0) layl[layn-1].partset=1; // Return without errors return(0); } int p_len() /* // Receive a length specification // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].len=atoi(synscanstring()); // Return without errors return(0); } int p_frac() /* // Receive a fraction specification // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].frac=atoi(synscanstring()); // Return without errors return(0); } int p_mm() /* // Receive a mm conversion factor // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].conv=1000.0; // Return without errors return(0); } int p_cm() /* // Receive a cm conversion factor // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].conv=100.0; // Return without errors return(0); } int p_inch() /* // Receive an inch conversion factor // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].conv=1.0/0.0254; // Return without errors return(0); } int p_mil() /* // Receive a mil conversion factor // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].conv=1.0/0.0000254; // Return without errors return(0); } int p_deg() /* // Receive an inch conversion factor // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].conv=cvtangle(1.0,0,1); // Return without errors return(0); } int p_conv(int negflag) /* // Receive a conversion factor // Return value : // zero if done or (-1) on error */ { fieldl[fieldn].conv=atof(synscanstring()); if (negflag) fieldl[fieldn].conv*=(-1.0); // Return without errors return(0); } int get_camorig(string os, double ox=bae_planwslx(),double oy=bae_planwsly()) /* // Get the CAM origin // Return value : // zero if done, 1 if multiple origin symbol, (-1) if no origin symbol // Parameters : // string os : Origin symbol // double ox=bae_planwslx(): Origin X coordinate // double oy=bae_planwsly(): Origin Y coordinate */ { index L_NREF nref /* Named reference index */; int osmatch = 0 /* Origin symbol match count */; // Test the origin symbol name if (os=="") // No origin symbol; return without errors return(0); strlower(os); // Check if coordinate origin reference if (os==ORGREF) { // Coordinate origin ox=bae_planwsnx(); oy=bae_planwsny(); return(0); } // Search the origin symbol forall (nref where nref.NAME==os) { // Set the origin coordinates ox=nref.X; oy=nref.Y; osmatch++; } // Test the origin symbol match count if (osmatch==1) // Origin symbol matched return(0); if (osmatch>1) // Multiple origin symbol match return(1); // No origin symbol matched return(-1); } int varfunc(string dstr,int dint,double ddbl, int dval,int dtype,string dtable,string dfield,int didx) /* // Variant data query callback function // Return value : // zero if done or (-1) on data error // Parameters : // string dstr : String/Date data // int dint : Integer/Boolean data // double ddbl : Float data // int dval : Data valid flag // int dtype : Data type // string dtable : Data table name // string dfield : Data field name // int didx : Data output field index */ { int i /* Loop control variable */; // Check the data field switch (didx) { case 1 : curvar=dint; break; case 2 : for (i=varn;i=varn) varn=curvar+1; break; default : ; } // Return without errors return(0); } // User Language program end