#8742
Yutaka Emura
Keymaster

This is an example of the macro that opens the next .txt file in the same folder as the opened file.


// This macro opens the next ".txt" file in the current folder.
//
sFolder = document.Path;
if( sFolder != "" ){
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFolder(sFolder);
fc = new Enumerator(f.files);
sItem = "";
for (; !fc.atEnd(); fc.moveNext()) {
if( fc.item().name == document.Name ) {
for( fc.moveNext(); !fc.atEnd(); fc.moveNext()) {
n = fc.item().name.lastIndexOf(".");
if( n != -1 ){
if( fc.item().name.slice( n ) == ".txt" ){
sPath = sFolder + "" + fc.item().name;
try {
editor.OpenFile( sPath );
}
catch(e){
}
break;
}
}
}
break;
}
}
}