Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #8736
    user
    Participant

    hello

    when you open an image file with Windows XP Image Viewer, and you click ENTER, it opens the next (in alphabetical order) image file that exists in the current folder

    can Emeditor do the same with txt files ?

    to open the next file in the current folder using a key shortcut (maybe not ENTER, but some else)?

    thanks

    #8738
    Yutaka Emura
    Keymaster

    Hi user,

    You could write a macro to view the next text file in the current folder by pressing a shortcut key.

    #8741
    user
    Participant

    can you tell me please how that macro should be
    thanks

    #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;
    }
    }
    }

    #8743
    user
    Participant

    thanks and what are the hotkeys to view the next/previous txt file?

    #8744
    Yutaka Emura
    Keymaster

    You can assign any shortcut key from the configuration properties > Keyboard tab. You can select this macro in the My Macros category, and then assign a new key.

    #8745
    user
    Participant

    does this work for the ‘previous’ txt file as well?
    thanks

    #8747
    Yutaka Emura
    Keymaster

    No, it doesn’t work with previous text file.

    #8751
    tonne
    Participant

    Prev-file version…


    // This macro opens the prev ".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 ) {
    try {
    editor.OpenFile( sPath );
    }
    catch(e) {
    }
    break;
    }
    else {
    n = fc.item().name.lastIndexOf(".");
    if( n != -1 && fc.item().name.slice( n ) == ".txt" )
    sPath = sFolder + "" + fc.item().name;
    }
    }
    }
    #8752
    user
    Participant

    that is very useful thanks
    but why it appears not well formatted? can you format it as the previous script?
    thanks

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.