As if I've never written a script before - how to debug

Started by bnewman, December 22, 2020, 10:31:08 PM

Previous topic - Next topic

bnewman

I wrote a few fairly complicated scripts about two years ago and have never needed to change it ...until now. I am trying to get back to the basics and it's as if I had never written before. I have some almost embarrassingly newbie questions about simply starting to debug. I simply want to start by entering my current script for debugging. I have the developer localhost port configured for 49777. What I cannot figure out is how to get my script loaded into the browser but not start running. To make matters worse: my default browser is Firefox, but I want to do the debugging in Chrome, which is slightly preferred, but I don't know what to type for the URL to point to my script. (unrelated, but my standard editor for the script is Notepad++).

I tried looking onto existing posts to see an answer to this basic question, but didn't find anything.

help.

ubacher

QuoteWhat I cannot figure out is how to get my script loaded into the browser but not start running.

If you put the word debugger into your code at the start it will stop execution (like a breakpoint) but only if you are running in debug mode.
In normal operation debugger is ignored.

Mario

The easiest way to debug apps is to load them into the browser. All you need to know is the URL of your app.
You can just right-click on your app in the App Manager and then select the "open App in web browser". Create a bookmark so you can run your app later via this URL (IMatch must be running).

When you load a HTML page (aka your script/app) the browser will execute it automatically.
You can then switch the browser to developer mode with <F12> and in the "Source" tab set a breakpoint at the entry point for your script.
For regular scripts this is usually the

$(document).ready(function () {

statement. Now press <F5> to reload your app and the browser will break at the break point.
See: https://developers.google.com/web/tools/chrome-devtools/javascript in the Google documentation for more info.

You can also debug an app running "in" IMatch via the remote debugging. This is usually only needed for service apps or Import & Export apps, but rarely.
It is much easier to run your app directly in the browser.
If you must debug this way, the address you enter in chrome is http://localhost:<debug port>. Chrome then displays a list of all apps running in IMatch and you can just click the app to open the debugger.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook