Viewing 1 post (of 1 total)
  • Author
    Posts
  • #5598

    shaohao
    Member

    This Macro is useful when you are writing C/C++ code with EmEditor. It will switch between .h and .c/.cpp files.


    #title = ""
    #tooltip = "C/C++<->H"

    fso = new ActiveXObject( "Scripting.FileSystemObject");

    // get file full name
    fn = document.FullName;

    // get base name and extension
    base = fso.GetParentFolderName(fn) + "" + fso.GetBaseName(fn);
    ext = fso.GetExtensionName( fn);
    if ( ext == "") Quit();

    // get file name to be opened
    if ( ext.toLowerCase() == "h") {
    fn = base + ".cpp";
    if ( ! fso.FileExists( fn)) fn = base + "c";
    } else if ( ext.toLowerCase() == "c" || ext.toLowerCase() == "cpp") {
    fn = base + ".h";
    } else {
    Quit(); // unsupported
    }

    // open the file
    if ( fso.FileExists( fn)) editor.OpenFile( fn, 0, eeOpenAllowNewWindow);
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Share with friends... Tweet about this on TwitterShare on FacebookShare on Google+Email this to someone