You are here: PSPad forum > English discussion forum > Re: How can I listen / monitor changes in editor and log-win?

Re: How can I listen / monitor changes in editor and log-win?

#1 How can I listen / monitor changes in editor and log-win?

Posted by: Professor Bernd | Date: 2019-10-09 18:30 | IP: IP Logged

I'm working on a few tools in VBScript and need to determine if a change occurs in the editor or log window.

- In the editor I want to execute code when text is highlighted.

- In Log-Win I want to format the error line after a compiler has written its output.

- etc.

In my VBScript how can I detect when a change happens?

Options: Reply | Quote | Up ^


#2 Re: How can I listen / monitor changes in editor and log-win?

Posted by: pspad | Date: 2019-10-09 18:57 | IP: IP Logged

Hello

PSPad doesn't support events for scripting.
Personally, I can't imagine to execute script during highlighting. It will deadly decrease speed of highlighting. All highlighting is made online based on code rules.

I don't understand "I want to format log windows code". Can you give me some example?

Options: Reply | Quote | Up ^


#3 Re: How can I listen / monitor changes in editor and log-win?

Posted by: Professor Bernd | Date: 2019-10-10 07:43 | IP: IP Logged

Hello, thanks for your quick answer.

Please excuse me very much, it is my mistake. What I actually meant: In the editor I want to execute code when text is selected.

Purpose: When the user selects a word (or part of a word), the script should highlight all identical occurrences.
.

- Format log windows code -

My log parser is: %F(%L,%C) : %E

This works well, it finds errors such as "... (123,14) ...", sets an red error marker and jumps to the error line in the editor when I double-click. Everything fine.

But it does not find errors like "... (123) ...", no error marker, no jump.

image

Unfortunately the log-parser does not allow wildcards. If I change the log-parser to %F(%L) : %E it finds both error forms, but the column specifications are missing. So I thought I'd check the text in the log-win with VBScript and add the column specification (",1" as dummy).

I found a way in VBScript to start the code automatically with PSPad (init section), but no way to run the code all the time to notice changes in the editor or log-win.

All codes with do-loop and "Sleep", "Wait", "Timeout", etc. totally blocked PSPad, or had other unwanted effects. Maybe it would work with a timer, but I searched for days and found no possibility for VBScirpt. I have a code for an (API-)timer in VB-Classic, but found no way to convert it to VBScript.

For that and for some other things winking smiley I would need a way to detect changes in the editor and log-win.

Options: Reply | Quote | Up ^


#4 Re: How can I listen / monitor changes in editor and log-win?

Posted by: vbr | Date: 2019-10-10 23:42 | IP: IP Logged

Hi,
I'm afraid I can't help with the most topical problem witch script usage in your case, but for the mentioned log parser, you shoud be able to use the basic wildcard - asterisk * for "(any number of) anything", which might solve some problems in matching the error message. However, it is not a complete regex or similar, hence, you can't use e.g. optional pattern parts, which might or might not appear in the error line.

However, currently there aren't any triggers or program events available via scripting - the scripts can now be called only in the script menu or via keyboard shortcut. (Hence, if otherwise everything works in your script, you'll currently need to call some shportcut after making a selection.)
I am not sure whether a custom timer calling some handling function might be viable, but is seems, that the underlying WSH scripting results in generally blocking calls for the program; possibly using a separate process might help in this areas, but I don't know, whether it is at all available in the scripting context.

Regards,
vbr

Options: Reply | Quote | Up ^


#5 Re: How can I listen / monitor changes in editor and log-win?

Posted by: pspad | Date: 2019-10-11 09:22 | IP: IP Logged

Hello

If you have more error "formats" in one output, I can offer you solution to add 2-3 log parser formats and all will be applied.

Options: Reply | Quote | Up ^


#6 Re: How can I listen / monitor changes in editor and log-win?

Posted by: pspad | Date: 2019-10-11 09:25 | IP: IP Logged

Related to events launched scripts.
For me it is no problem to add events - list of events with assigned scripts.

But there is a risk if skript will make problem it can hang-up editor.
E.g. script will be launched when text is selected. But if you will change selection in script, it will cal script and you will get endless loop.

Options: Reply | Quote | Up ^


#7 Re: How can I listen / monitor changes in editor and log-win?

Posted by: Professor Bernd | Date: 2019-10-11 17:42 | IP: IP Logged

pspad:
If you have more error "formats" in one output, I can offer you solution to add 2-3 log parser formats and all will be applied.

Hi Jan, this is an excellent idea! I would be very happy. smiling smiley

pspad:
For me it is no problem to add events - list of events with assigned scripts.

Also for this: Excellent idea! I am happy! smiling smiley

.

Related to events launched scripts.

pspad:
But there is a risk if skript will make problem it can hang-up editor.

You're right about that! But I would like to try it anyway. winking smiley

I know that you are very busy and therefore I work on the extensions via VBScript to relieve you. But ... you do the work much better than me! grinning smiley

.

Hi vbr.

Thanks a lot for the tips.

I was wrong, a * can be used in log parser and it makes that the log parser jumps to the error line.

But between you and me: If Jan installs 3 log-parser, that's much better! tongue sticking out smiley

WSH scripting: You're right about that, too. Also here applies: Better if Jan installs this! I am glad! smiling smiley

Edited 1 time(s). Last edit at 2019-10-11 17:43 by Professor Bernd.

Options: Reply | Quote | Up ^






Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR