Viewing 1 post (of 1 total)
- AuthorPosts
- March 21, 2008 at 6:02 pm #5598shaohao MemberThis 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);
- AuthorPosts
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.