Tagged: macro filter negative flag
- AuthorPosts
- October 12, 2024 at 10:35 pm #30062Reg JohnsonParticipant
After running a negative filter, the negative filter flag is set and new filters are also negative.
How do I reset the flag (regardless of current state) in a macro so that subsequent filter commands are “positive” and not “negative”?
October 13, 2024 at 3:19 pm #30063Patrick CParticipant#title = "Set the negative filter flag to inactive" #language = "V8" #async = "off" // get the filter toolbar’s negative status (id 3916) let negFilterStatus = editor.QueryStatusByID(3916); // if negative is enabled → disable by toggling if ((negFilterStatus & eeStatusEnabled) === eeStatusEnabled) { // case negative is enabled → run the toggle command editor.ExecuteCommandByID(3916); }
EmEditor Help: Negative (Filter Toolbar) command
EmEditor Help: QueryStatusByID MethodRegarding
(negFilterStatus & eeStatusEnabled) === eeStatusEnabled
:
EmEditor uses bitwise flags for statuses. The&
is a bitwise and.October 13, 2024 at 3:45 pm #30064Patrick CParticipantCorrection: One must test for eeStatusLatched.
#title = "Set the negative filter flag to inactive" #language = "V8" #async = "off" // get the filter toolbar’s negative status (id 3916) let negFilterStatus = editor.QueryStatusByID(3916); // if negative is enabled → disable by toggling if ((negFilterStatus & eeStatusLatched) === eeStatusLatched ) { // case negative is enabled → run the toggle command editor.ExecuteCommandByID(3916); }
EmEditor Help: Negative (Filter Toolbar) command
EmEditor Help: QueryStatusByID MethodRegarding
(negFilterStatus & eeStatusLatched) === eeStatusLatched
EmEditor uses bitwise flags for statuses. The & is a bitwise and.October 13, 2024 at 10:45 pm #30065Reg JohnsonParticipantThanks!
I wish there was a simple “one-line” way to just reset all flags.
October 13, 2024 at 11:09 pm #30066Reg JohnsonParticipantActually, I am not sure how to make this work. I am using vbscript.
I tried running this command after doing a negative filter:
“editor.ExecuteCommandByID(3912)”And the negative filter was still set and any search resulted in a negative search.
October 14, 2024 at 7:35 am #30067Patrick CParticipantThe VBScript Command is
editor.ExecuteCommandByID 3916
EmEditor Help: Negative (Filter Toolbar) command——————————————————————-
The JavaScript above expressed as VBScript is#title = "Set the negative filter flag to inactive" #language = "VBScript" #async = "off" ' get the filter toolbar’s negative status (id 3916) Dim negFilterStatus negFilterStatus = editor.QueryStatusByID(3916) ' if negative is enabled -> disable by toggling If ((negFilterStatus And eeStatusLatched) = eeStatusLatched) Then ' case negative is enabled → run the toggle command editor.ExecuteCommandByID 3916 End If
——————————————————————-
VBScript code to set all filters to 0 is (its ugly, couldn`t think of something better):#title = "Set the negative filter flag to inactive" #language = "VBScript" #async = "off" ' reset the filters list Dim filtersList Set filtersList = document.filters filtersList.Clear filtersList.Add "dummy", False, 0, 0 ' add a single item with all flags set to 0 (off) document.filters = filtersList ' apply the filter → flags are now 0 filtersList.Clear ' remove the filter again (removes ‘dummy’) document.filters = filtersList ' empty filter + the flags stay as they are
——————————————————————-
Note that VBScript is deprecated. - AuthorPosts
- You must be logged in to reply to this topic.