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.


//Open a File dialog

string                    SchematicName;                                // Schematic file name
string                    SchematicPath;                                // Project path
string                    OutputExt= ".txt";
int                        OutputFormat = 0;                            // 0 = plain text, 1 = HTML, 2 = comma separated values
enum                    {OF_TEXT, OF_HTML, OF_SPREADSHEET};
string                    Output = "FudgeArroo FudgeArree \n";        // Easy to spot nonsense Output to file

project.schematic(SCH) {                                            // Get the path and file name of the schematic
    SchematicPath = filedir(SCH.name);
    SchematicName = filename(SCH.name);
}

void SaveOutput(void)                                               // This sets up the function: must be set up before called.
{
    string FilePath;
    string FileName;
    string a[];

    FileName=filesetext(SchematicName,OutputExt);
    FilePath = SchematicPath + "\\" + FileName;
    Output += "FileName=" + FileName + "\n";                         // Add the file name to the stuff that will be written to the file
    Output += "FilePath=" + FilePath + "\n";                         // Add the file path to the stuff that will be written to the file
    
    FileName = dlgFileSave("Save Output", FilePath, "Output files (*" + OutputExt + ");;All files (*)");
    if (!FileName) return;
    if (!fileglob(a, FileName) || dlgMessageBox("File '" + FileName + "' exists\n\nOverwrite?", "+&Yes", "-&No") == 0) output(FileName, "wt") { 
        if (OutputFormat == OF_TEXT) printf("%s", Output);
    }
}
   
SaveOutput();                                                          // Call the SaveOutput function.  

exit(0);


When you look inside the text file written to disk you should see something similar to this:

FudgeArroo FudgeArree 
FileName=AMS_proto_3.txt
FilePath=C:/Users/freemonsandlewould/Documents/Schematics/ReaderProto/AMS_proto_3.txt

Of course it will not be the exact same as this because it reads your schematic name to form the filename.

Categories: Eagle PCBElectronics

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *