Is there a way to 'Repeat' a command 'n' times

SyntaxEditor for Windows Forms Forum

Posted 7 years ago by Mike Dempsey - Sr. Developer, Teradata Corp
Version: 12.1.0300
Avatar

My current editor has a RepeatCount property that is normally set to 1.

If I set it to say 10 then the next 'command' will be executed 10 times. (after which the count automatically resets to 1)

The 'command' can be something as simple as typing a character or highlighting a letter, or more often, executing a keyboard macro.

In the case of macros I could add a count field to the dialog that allows the user to select which macro they want to execute (assuming they dont execute it via a keyboard shortcut) and then simply execute the macro inside a For loop.

But does SyntaxEditor either have a similar property, or have a method/event that I can hook into which is called before EVERY command [including typing a character] so that I can implement a loop there instead. 

Thanks
Mike

Comments (7)

Answer - Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mike,

Sorry but I don't believe we have anything for trapping commands in the way you'd need. 

As far as building a looping command, you could probably implement a custom class that inherits EditCommand (just like all our built-in commands) and could use it as a "wrapper" for another EditCommand.  Then just execute the wrapped command however many times you need for your loop.


Actipro Software Support

Posted 7 years ago by Mike Dempsey - Sr. Developer, Teradata Corp
Avatar

OK I'll have to look into doing that.

Since the guy that developed our current tool was an ex Microsoft Visual Studio developer I assumed it was a feature of VS. But if it is I can't find it.

I'm suprised it's not since it is a VERY useful feature.

(How many times have you needed to create a test string of 'n' characters and screwed up your counting... or had to run a macro 200 times. I know I do both of those quite often.)

Posted 7 years ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Sorry, but the only scenario I can think of it could be useful is debugging and testing.

For every other scenario you can just repeat the commands you fire.

Just imagine every single command would be repeated, let's say 10 times. You press the right arrow key, you jump forward 10 characters. You press space, you insert 10 spaces, etc...

I mean it would be nice/usefull to have an event that contains the command that is about to be processed. Here you could do everything. You could cancel it, modify it or repeat it if you want to. But repeating every single command with a global number makes no sense, because you cannot distinguish between different commands.


Best regards, Tobias Lingemann.

Posted 7 years ago by Mike Dempsey - Sr. Developer, Teradata Corp
Avatar

Yes, debugging and testing is the most useful case.

That and executing a macro. I frequently have a file that needs to be modified in such a way that can not be done using regular expression Replace commands so I write a macro that updates one instance and moves to the next. I then use Repeat 500 to execute the macro 500 times. (assuming there are less that 500 instances in the file it will completely convert the file)

Note that Repeat ONLY repeats the next 'command' you execute - not all future commands.

Posted 7 years ago by Mike Dempsey - Sr. Developer, Teradata Corp
Avatar

I understand the idea of creating my own class that inherits from EditCommand.
That requires me to implement an Execute() function that could perform the looping when needed.

But I dont understand how that will intercept all commands executed by my Syntax Editor control, 
or how to execute those commands within my loop. (The context I am passed does not have an Execute method)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Mike,

Per my original reply, I don't believe we have a way for you to track which commands are getting executed.

For executing the wrapped commands, you'd probably just call their own Execute methods, passing the same parameters that were passed to your custom wrapper.


Actipro Software Support

Posted 7 years ago by Mike Dempsey - Sr. Developer, Teradata Corp
Avatar

So in addition to creating my own 'controler' class that would implement the loop I would have to derive my own class from each of your specific command classes that I want to be able to repeat. Then each of my sub classes would call my control class which in turn calls the Execute function of the passed parameter. (within a loop) 

I guess I will need to limit the Repeat functionality to only the most commonly used cases (Key Typing, Paste, and Macro execution) since currently almost any command can be repeated. (There a handful like Cut, Copy, SelectAll that dont make sense, but the majority of commands are repeatable) 

The latest build of this product (v2018.1 build 0341) was released 7 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.