macro – EmEditor (Text Editor) https://www.emeditor.com Best Text Editor, Code Editor, CSV Editor, Large File Viewer for Windows (Free versions available) Sat, 28 Oct 2017 01:33:27 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 Option for filters.Import() to append to current filter rather than only replace https://www.emeditor.com/forums/topic/option-for-filters-import-to-append-to-current-filter-rather-than-only-replace/ Sat, 28 Oct 2017 01:32:20 +0000 https://www.emeditor.com/forums/topic/option-for-filters-import-to-append-to-current-filter-rather-than-only-replace/ It would be extremely useful to have an option for document.filters.Import() that would allow it to append the imported filter to the (possibly) already applied filter of the current document, rather than always just replacing it, as it currently does.

This option could typically be implemented as a second (optional) flags parameter to the filters.Import() method, which would make it fully backwards compatible too.

As you can understand, this would make it possible for macros to perform extremely complex dynamic filtering of documents, depending on the logic of the macro itself, while the filter templates that it uses can still be originally created by humans and stored in the different filter files that are imported by the macro, step-by-step, in this way.

Pretty please with sugar on top could we have this new flag for document.filters.Import()? :-)

]]>
Serious bug regarding macros mapped to shortcuts! https://www.emeditor.com/forums/topic/serious-bug-regarding-macros-mapped-to-shortcuts/ Fri, 27 Oct 2017 12:39:14 +0000 https://www.emeditor.com/forums/topic/serious-bug-regarding-macros-mapped-to-shortcuts/ I just found a serious bug regarding macros mapped to shortcuts.

I have several such mappings configured in my EmEditor, and when I create and insert a new macro and insert it before any such shortcut-mapped macros, all mappings of shortcuts to macros that are after it in the defined macro order (i.e. the order in which the macros appear in the macro toolbar and the “Customize macros” dialog box) will shift, i.e. the shortcut mappings of those will now point to other macros than before!

This is very dangerous (depending on what the macros do of course), and it is seemingly because the mappings of the shortcuts point at indexes in the macro list, rather than the macro items/files in the list themselves (i.e. no matter if they are moved in the list or not. in this case by having other macros inserted before them).

This should probably be fixed ASAP in order to avoid accidents that may cause data loss for customers.

]]>
How to include other macros DYNAMICALLY from macros? https://www.emeditor.com/forums/topic/how-to-include-other-macros-dynamically-from-macros/ Fri, 27 Oct 2017 01:55:50 +0000 https://www.emeditor.com/forums/topic/how-to-include-other-macros-dynamically-from-macros/ The #include directive in EmEditor macros is very useful for simple includes of other macro files (typically for simple static code reuse).

BUT, I need to include other macros dynamically. I.e., depending on certain conditions, I need to include (or otherwise execute) different other macros from my macro, and the #include directive only seems to support a static string as its parameter, right?

Example:

Works:
#include "my_other_macro.jsee"

Does NOT work:
#include "my_other_" + "macro.jsee"

So, how can I call/execute other macros dynamically from my EmEditor macros?

]]>
How to get the name of the currently executing EmEditor macro? https://www.emeditor.com/forums/topic/how-to-get-the-name-of-the-currently-executing-emeditor-macro/ Fri, 27 Oct 2017 01:35:42 +0000 https://www.emeditor.com/forums/topic/how-to-get-the-name-of-the-currently-executing-emeditor-macro/ I need to get the name of the currently executing macro, from inside the macro itself – is this possible in EmEditor?

Normally in Javascripts executed inside Windows Scripting Host, you can use the Wscript.FullName property for this, but the Wscript object doesn’t seem to be available at all inside EmEditor macros?

]]>
Enhancement: Possibility to provide macro parameters from the command line https://www.emeditor.com/forums/topic/enhancement-possibility-to-provide-macro-parameters-from-the-command-line/ Wed, 06 Sep 2017 07:13:14 +0000 https://www.emeditor.com/forums/topic/enhancement-possibility-to-provide-macro-parameters-from-the-command-line/ As described in this forum thread, it would be super useful to be able to provide parameter data to macros directly from the command-line, in order to be able to use self-contained command-lines for advanced EmEditor tasks on a daily basis (like for example in my case, integrated with other software tools that can invoke external tools by using such command-lines).

It could look for example like this on the command line:

emeditor.exe c:\some_dir\some_target_file.txt /mf c:\my_emeditor_macros\delete_every_nth_line.jsee -macroparam “n=3”

Or like this for multiple parameters:

emeditor.exe c:\some_dir\some_target_file.txt /mf c:\my_emeditor_macros\delete_every_nth_line.jsee -macroparam “n=3” -macroparam “start_at_line=2”

Or, to remove the complexity of named parameters, simply using unnamed ordered parameters instead, like this:

emeditor.exe c:\some_dir\some_target_file.txt /mf c:\my_emeditor_macros\delete_every_nth_line.jsee -macroparam 3 -macroparam 2

From inside the macro, the parameter data could for example be accessed from a Javascript object that you provide, e.g. called “MacroParameters”, which could either in the simple case with unnamed ordered parameters only be a simple array of strings, or in the little more complex case with named parameters, e.g. be an “associative array” (using Javascript objects and properties), or alternatively perhaps two simple arrays of strings, where one contains the parameter names and one contains the values.

I really hope that you will consider this enhancement suggestion, since I think it would be a highly useful feature to go with the already super useful possibility to execute macros from the command-line with the “/mf” switch. Thanks for listening!

]]>
How to provide parameters for macros executed from the command line? https://www.emeditor.com/forums/topic/how-to-provide-parameters-for-macros-executed-from-the-command-line/ Mon, 04 Sep 2017 21:53:38 +0000 https://www.emeditor.com/forums/topic/how-to-provide-parameters-for-macros-executed-from-the-command-line/ Using the /mf switch, it is possible to execute a macro on any given file directly from the command line, which is very good!

One big problem with this though is that I haven’t been able to find any way to provide parameters for this macro from this same command line – how can this be done?

A simple example:
I have a macro that will delete every n:th line from the current file, and I want to be able to provide this “n” value (i.e. so that it can delete for example every second line, every third line, every fourth line etc, based on my current choice).

This must be possible somehow, right? But how? I cannot find anything like this in the EmEditor command-line reference?

]]>
Possible to make markers in the EmEditor sidebar from macros? https://www.emeditor.com/forums/topic/possible-to-make-markers-in-the-emeditor-sidebar-from-macros/ Thu, 06 Oct 2016 00:54:54 +0000 https://www.emeditor.com/forums/topic/possible-to-make-markers-in-the-emeditor-sidebar-from-macros/ In order to be able to implement my previous feature suggestion for EmEditor in a macro myself, I would need some way to create graphical markers (or at least text-based markers) in the left sidebar of EmEditor (i.e. where the line numbers and yellow/green change-indicator is normally shown).

Is this currently possible?

If not, would you consider adding this to the macro capabilities of EmEditor?
(e.g. by adding a macro method that takes only two parameters: a line number in the document and a path to an image file on disk, possibly restrained in which sizes it could have, which would then paint this image in the left sidebar on the specified line in the document)

This would open up LOTS of possibilities for cool extra functionality for EmEditor that could be implemented directly from inside macros!

]]>
How to get the number of the last VISIBLE (filter-wise) line number in document? https://www.emeditor.com/forums/topic/how-to-get-the-number-of-the-last-visible-filter-wise-line-number-in-document/ Tue, 30 Aug 2016 22:51:22 +0000 https://www.emeditor.com/forums/topic/how-to-get-the-number-of-the-last-visible-filter-wise-line-number-in-document/ I’m using a macro (in Cell Selection Mode) to select all the data in the column where the “cell cursor” is currently at. It looks like this:

	document.selection.SetActivePoint(eePosCell, document.selection.GetActivePointX(eePosCell), 2, false);
	document.selection.SetActivePoint(eePosCell, document.selection.GetActivePointX(eePosCell), document.GetLines() - 1, true);

It works great when there is no active filter, but as soon as any line at the end of the file is currently filtered-out, it won’t work. It will then instead select all the columns including and to the left of the column where the “cell cursor” is currently at.

The simple explanation for this is that the expression “document.GetLines() – 1” will not move the cursor from the last (empty) line above it in the filtered data (because the line number of that line will still be less than “document.GetLines() – 1” if any lines have been filtered-out inbetween the end of the document and the last visible (= non-filtered out) line in the document). Thus, the cell cursor will “snap left” on the very last line of the file (which is always empty, therefore bringing the cell cursor all the way to the left, consequently selecting also all the columns to the left of the intended column).

So, my question is therefore: Is there any way to get the line numbers of only the visible lines (i.e. those that are not hidden by the filter) in a file, from a macro?

If not, how can I go about selecting the entire contents of a single column from a macro in the above described scenario?

Example data (with example line numbers to the left):

1: col1;col2;col3
2: 1;2;3
3: 11;22;33
4: 111;222;333
10:

In this case, lines 5-9 of the file have been filtered-out by a filter expression, therefore not being visible in the editor window.

So, what I want in this example is to get the number of the last visible line (i.e. nr 4, which is the last visible line before the very last line which in this case is nr 10, where the last one is always empty without any cells, except the “artificial” cell being placed to the very left), or any other method to reliably select the entire data contents (i.e. rows 2-4) of this column.

Are any of these two things currently possible from EmEditor macros, or could you otherwise possibly add the possibility to do any of these two things?

]]>
Macro scripting import/export of filter settings? https://www.emeditor.com/forums/topic/macro-scripting-importexport-of-filter-settings/ Thu, 14 Apr 2016 11:22:48 +0000 https://www.emeditor.com/forums/topic/macro-scripting-importexport-of-filter-settings/ The (very useful) filtering feature of EmEditor has import/export buttons in the “Advanced Filter” dialog.
I’ve been trying to script these operations with macros, but as soon as I perform an import/export while recording a macro, I only get the separate filter operations that I import dumped to the macro, instead of the import operation itself.

Scripting the import (and export) operation itself (with a possibility to provide the filename to be imported/exported) would be highly useful, so my question is if this is already possible, or if it could otherwise be implemented in the macro capabilities of EmEditor?

]]>
Unspecified errors https://www.emeditor.com/forums/topic/unspecified-errors/ Thu, 14 Apr 2016 06:42:37 +0000 https://www.emeditor.com/forums/topic/unspecified-errors/ When no text is selected, running a macro using eeReplaceSelOnly causes “unspecified error”.
This macro worked fine in the past.

[Prompt when End of Document is Reached] is enabled;
Run:
document.selection.find(str, eeFindNext | eeFindAround);
When it prompts me, canceling the dialog causes “unspecified error”.

By the way,
—–
Prompt when End of Document is Reached:
If this is checked, EmEditor will display a dialog box to prompt the user when Search reaches the end of the document.
—–
According to this description, shouldn’t EmEditor also prompt the user even when the Around option is off?
When the sound is muted, I often ignore the message on the status bar, and do [Find Next] one or two more times, till I see it reached the end…

]]>