In order to âdebugâ a macro, I wonder, if there is a way to display variable values etc. in some kind of alert-function, but it says in the introduction to macros that they are restricted? Am not sure from that, wether there is a way of displaying an alert or something similar?
I mean to present messages to the user / developer from JavaScript, for example something like:
let count = 100;
alert (count + âdata processedâ);
Or just print some value:
alert(count);
Quite similar to the usage of alert in plain JavaScript, just a means to easily present messages to developer / user.
Thanks a lot
Hello @Dimpflmoser
You can use console (console.log()) method for debugging. Unfortunately, alert feature use is not possible at the moment (we are working on it already).
Sorry for inconvenience.
we can use the --ascdesktop-support-debug-info flag so I did that
then what. Where do the logs go? do we type console.log("hello world");? I ran journalctl --follow as I normally would but nothing appears in the logs. Where is the console.log output?
it says " right-click any editable field on the top toolbar (for example, font list combo) and click Inspect Element" but nothing happens when I right click anywhereâŚ
Also, why does this flag need to be in the command line rather than being an option in the settings in the first place?
" 4. Open the debug console by pressing the F12 button.": Nothing happens when I presse F12. I found that I can right click on the bar in the middle to select âShow Devtoolsâ
â5. Click the debugger:///VM(XXX) link on the right of the line with the logging messageâ: there is no such thing
â6. Set a breakpoint by clicking the line number and run your script again.â: Nothing happens when I click on a line number. How can I set breakpoints?
Why isnât there a âdebugâ button in the macro editor to access this console rather than expecting people to find this?
The mentioned guide in this part of your post is related to server-based solution (F12 button for browser action). We are checking the situation with âright clickâ.
Update:
Thank you for pointing us to the situation with âright-clickâ, we are going to fix it with v.7.3.
As for other questions:
Also, why does this flag need to be in the command line rather than being an option in the settings in the first place?
Why isnât there a âdebugâ button in the macro editor to access this console rather than expecting people to find this?
We designed Desktop Editors this way, because a user doesnât need debug mode in most common scenarios of work with Desktop Editors. But I understand and noted your suggestion, probably one day we will come back to it.
Thank you one more time!
ok so, I had a look at v7.3 and couldnât spot any difference.
Regarding the first page on Debugging, this has more to do with app debugging which isnât what I was trying to do so thatâs my mistake and we can ignore.
On the second page regarding macro debugging, again, no change as far as I can tell. DevTools is a very useful tool but for some reason it is burried quite deep and hidden behind this right click â Show DevTools. Pressing F12 still does nothing for me and quite frankly, even if it did, there should be a button so the user knows itâs there. A debug console is a critical tool when writting macros, I really think that this DevTools window should be made more visible.
Ideally, it should be integrated directly in the Macros window. It doesnât need to be massive, perhaps a split screen at the bottom of the code like in VS Code would do. In any case, please add a button to show DevTools (e.g. next to âRunâ) of people arenât going to know itâs there.
Also, the window canât be resized and 1/4 of the screen size is too small for some decent code, would it be possible to allow resizing so it can be made full screen and allow hiding/resizing the left panel? the left panel is taking too much valuable real estate in this window at the moment.
You mentioned the guide which is related server-based Document server (stand alone installation of entire Document server). This way F12 works properly. For Desktop editors you have to use F1 button as it is described here: ONLYOFFICE Api Documentation - Debugging
About Macros tab screen re-size, we have noted your requested and will discuss it internally.
Hello @Kaligula
My approch for macro debugging is to wrap my code with following Skeleton.
Its allows to LOG any strings one after one to a choosen worksheet column.
> (function() {
> var oTraceRange = Api.GetActiveSheet().GetRange("L1");
> oTraceRange.Clear();
> function LOG(trace = "on y passe") {
> oTraceRange.SetValue(trace);
> oTraceRange.SetOffset(1, 0);
> oTraceRange.Clear();
> }
> try {
> LOG("Skeleton");
> // Here to write incoming you code ....
> }
> catch (e) {
> LOG(e);
> }
> LOG("fini");
>
> })();
You may also dedicate a full worksheet for logs : oTraceRange = Api.GetRange(âtrace!A1â);
Thank you for sharing your experience @jpp
Just to add a few words, you can check console logs in web-browser for running macro with this section that has been added to macro itself: