Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Using EM Macros in a batch job #7428
    DKlein
    Member

    Glitch 2 is gone. Thanks.

    Glitch 1 maybe isn’t so bad. These macros will be used in a production environment (different machines will use them) and will be customized in different folders (may have the same name). Putting them into a My Macros will not work. For instance, there may be a AddProject.vsee in each customers folder that adds the unique project ID to a file with Command Line “EMC filename AddProject”.

    It appears EM must be keeping a perminate list (in the registry?) of trusted macros and the folder it is in as you only have to use the “trust” prompt the first time even after booting. This would be per machine as everybody has to trust it once. I suppose you have to do this because these macros are powerful programs and can take over the users computer. This prevents a virus starting up EM to run its bad macro.

    Thanks for our help. I’m very impressed with your responsiveness and the product in general.

    in reply to: Using EM Macros in a batch job #7426
    DKlein
    Member

    Thanks, pretty cool. Just two little gliches left.

    So I can make a batch job named EMB.BAT that contains:
    “c:program filesemeditoremeditor.exe” \%1 /sp /cd /mf \%2.jsee

    So the user can type on the command line: EMB infile macroname
    The macro runs on the file and returns to the command line prompt.

    The macro is:
    // If the line contains a “tag” of any length starting at TagStart
    // Replace occurrences of SearchText with ReplaceText if in the column “window”.
    //
    // User modifies these settings:
    Tag = “020”;
    TagStart = 1;
    SearchText = “Kl”;
    ReplaceText = “Sss”;
    WindowStart = 4;
    WindowEnd = 14;
    //
    if( !editor.EnableTab ){
    editor.EnableTab = true;
    alert( “Enabling tab for editor. Please restart micro.” );
    Quit();
    }
    if (WindowStart > WindowEnd)
    {
    alert (“Window Start greater than Window End”);
    Quit();
    }
    if (SearchText.length > WindowEnd – WindowStart + 1)
    {
    alert (“Search term length is greater than the Window”);
    Quit();
    }
    windowStop = WindowEnd – SearchText.length + 2;
    document.selection.StartofDocument();
    y = 1;
    replacements = 0;
    do
    {
    // Move to next line; then at EOF if can’t get the active location
    document.selection.SetActivePoint( eePosView, 1, y );
    if( y != document.selection.GetActivePointY( eePosView ) ) break;
    document.selection.SetActivePoint (eePosView, TagStart, y, true);
    document.selection.SetActivePoint (eePosView, TagStart + Tag.length , y, true);
    if( document.selection.Text == Tag )
    {
    windowIndex = WindowStart;
    do
    {
    document.selection.SetActivePoint( eePosView, windowIndex, y , false);
    document.selection.SetActivePoint( eePosView, windowIndex + SearchText.length, y , true);
    if ( document.selection.Text == SearchText) //If found
    {
    document.selection.Text = ReplaceText;
    replacements++;
    }
    windowIndex ++;
    } while (windowIndex < windowStop)
    }
    y++;
    } while( true );
    inFile = document.FullName;
    results = replacements + ” replacement count on ” + inFile

    // Interactive mode
    //document.selection.StartofDocument();
    //alert(results);
    //

    //Batch mode
    document.Save(inFile);
    extension = inFile.lastIndexOf(“.”);
    resultFile = inFile.substring (0, extension + 1) + “emc”;
    fso = new ActiveXObject (“Scripting.FileSystemObject”);
    s = fso.CreateTextFile(resultFile);
    s.writeline(results);
    s.Close();
    editor.ExecuteCommandByID (4119); //Close down Em

    —-
    Glitch 1:
    The first time I run the batch it shows EMEditor and askes if this is a “trusted” macro and the user has to select the Yes button. On subsiquent runs EMEdit remembers it is trusted. Anyway to avoid the prompt?

    —-
    Glitch 2:
    If EmEditor already an instance, running the batch in a Command Line instance will shut EM instance down, too. The “/sp” isn’t doing anything in the EMB job above.

    —-
    EM Editor is close to replacing application we have that runs edit commands on files.

Viewing 2 posts - 1 through 2 (of 2 total)