How an Eagle PCB ULP User Language Program Can Alter a Schematic

I have used a ULP ( User Language Program ) called Smash.ulp to smash all the parts on the schematic many times.  ULP's by themselves are said to be unable to modify a schematic.  Smash.ulp generates a script file named Smash.scr.  Inside of Smash.scr you will see something like the following:


grid mil;
smash (2700 1400);
smash (3800 1400);
smash (500 6900);
smash (1400 7000);
smash (8500 6400);
smash (3100 6800);
smash (3400 6800);
smash (3700 6800);
smash (4000 6800);


The integers shown are in units of mils which is called out at the top of the list.  I verified indeed that these coordinates correspond to parts origins on the schematic which I ran Smash.ulp on.  So what Smash.ulp does is the following:

  1. create a list of smash commands for each component with their respective coordinates
  2. At the exit of Smash.ulp there is a statement that calls the script file named Smash.scr. That line is shown below:

exit("; SCR '" + ulp_path + "smash_all.scr';\n");

An Ultra simple Eagle PCB ULP User Language Program Tutorial to write to a file

I like simple examples for purposes of learning a programming language.  Something that does not clutter everything up leaving me with a million doubts.  The following Eagle ULP tutorial file writes an ASCII string to two different files.  The first file write demonstrate the default location of file writing and the second shows how to specify where you want the file written.  Notice the backslash character needs escaped because it is the escape character!  

 


output("fudge.txt", "wt"){ printf("Directly printed to file with output statement\n");}           //w= Write new file / t= Text mode
                                                                                                  //This did not work when located at bottom of file. Must not have been executed.  
                                                                                                  //It writes to the Eagle program directory! 
output("C:\\Users\\freemonsandlewould\\Documents\\Schematics\\Reader\\ULP\\farge.txt", "wt")
      { printf("Directly printed to file with output statement\n");}          
                                                                                                  //The backslash character must be escaped with another backslash
                                                                                                  //When you specify the entire path then it goes where you plan that it should
      
exit (0);   // Must have this or it errors out


A simple Eagle PCB ULP User Language Program to Open a file dialog and write to the file specified by it

This ULP ( User Language Program ) opens a file dialog automatically using the schematic name to form a file name in the dialog opened.  If you want you can change the name in the open dialog box.  It is a fairly simple program without all the extra stuff you see in this mind boggling script files.  I checked and was able to cut and paste the following into NotePad++ without getting html characters.