#usage "Example: Check all libraries in a directory\n" "

" "This is an example how to loop through all libraries in a directory " "and perform a device check." "

" "In this case, the device descriptions are checked for double bold tags. " "An error report error.txt is generated in the library directory." "

" "Load any library from the library directory and execute the ULP." "

" "Author: support@cadsoft.de" // THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED string a[], par, lbr_path, dest, cmd = "", s, progname; int lbrpnt, x; //-------------------------------------------------- string checklbr (UL_LIBRARY L) { int errflag = 0; string h; L.devices(D) { h = ""; sprintf(h,"%s",D.description); h = strlwr(h); if (strstr(h, "") >= 0 && !errflag) { cmd += L.name+"\n"; errflag = 1; } } if (errflag) return "***"; else return ""; } //---------------------------------------------------- string get_progname(void) { string s = strsub(argv[0], 0, strlen(argv[0])-4); string p = s; char c = '/'; int pos = strrchr(s, c); if (pos >= 0) { p = strsub(s, pos + 1); } return p; } //-------- main program -------------------------------------------------- progname = get_progname(); library(L) { lbr_path = filedir(L.name); } dest = lbr_path+"error.txt"; lbrpnt = strtod(argv[1]); int n = fileglob(a, lbr_path+"*.lbr"); if (n) { if (lbrpnt < 1) { // first run // initial actions, e.g. headline //------------------------------------------------------------------------ output(dest, "wt") printf("Faulty Libraries marked with ***\n\n"); //------------------------------------------------------------------------ exit("OPEN "+lbr_path+filename(a[0])+";\nRUN "+progname+" 1"); } else { // next runs library(L) { // insert here whatever you want to do with the current library //------------------------------------------------------------------------ s = checklbr(L); output(dest, "at") printf("%s%s\n",L.name, s); //------------------------------------------------------------------------ lbrpnt++; sprintf(par, "%d", lbrpnt); if (lbrpnt == n) exit(0); exit("OPEN "+lbr_path+filename(a[lbrpnt])+";\nRUN "+progname+" "+par+" \n"); } } }