Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2022-09

Inspect variables and fields in the browser console?

8 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

Hello,

as per the subject, how do I inspect the fields of my application in the browser console?
I suspects they're somewhere under rtl. but the autocompletion didn't help me.

Bye

Luca
Mattias Gaertner
to Luca Olivetti
Hello, as per the subject, how do I inspect the fields of my application in the browser console?

Do you mean, how to write all properties of an object to the browser console?
Or to inspect fields in the browser debugger?

I suspects they're somewhere under rtl. but the autocompletion didn't help me.

Mattias

Luca Olivetti
to Mattias Gaertner

El 21/9/22 a les 14:06, Mattias Gaertner via Pas2js ha escrit:

Show quoted text 11 lines
On Wed, 21 Sep 2022 11:43:48 +0000 (UTC) Luca Olivetti via Pas2js wrote: > Hello, > > as per the subject, how do I inspect the fields of my application in > the browser console? Do you mean, how to write all properties of an object to the browser console? Or to inspect fields in the browser debugger?

The latter. When I put a breakpoint inside a procedure, I can only see local variables.

Bye

Luca
Luca Olivetti
to Luca Olivetti

El 21/9/22 a les 17:08, Luca Olivetti via Pas2js ha escrit:

Show quoted text 15 lines
El 21/9/22 a les 14:06, Mattias Gaertner via Pas2js ha escrit: > On Wed, 21 Sep 2022 11:43:48 +0000 (UTC) > Luca Olivetti via Pas2js wrote: > >> Hello, >> >> as per the subject, how do I inspect the fields of my application in >> the browser console? > > Do you mean, how to write all properties of an object to the browser > console? > Or to inspect fields in the browser debugger? The latter. When I put a breakpoint inside a procedure, I can only see local variables.

So, is it possible or not to inspect fields defined in my TBrowserApplication?

Bye

Luca
Mattias Gaertner
to Luca Olivetti
Show quoted text 9 lines
[...] >> Or to inspect fields in the browser debugger? > > The latter. When I put a breakpoint inside a procedure, I can only > see local variables. So, is it possible or not to inspect fields defined in my TBrowserApplication?
It is possible.
I assume, your program contains a
var
  Application: TBrowserApplication;

For example in Chrome when paused on a breakpoint look at the right side under Watch and Breakpoints there is Scope.
Under Scope there is Local and Closure. The Application should be there. Depends on where your breakpoint is.

Mattias

Luca Olivetti
to Mattias Gaertner

El 23/9/22 a les 12:37, Mattias Gaertner via Pas2js ha escrit:

Show quoted text 22 lines
On Thu, 22 Sep 2022 15:14:48 +0000 (UTC) Luca Olivetti via Pas2js wrote: > [...] >>> Or to inspect fields in the browser debugger? >> >> The latter. When I put a breakpoint inside a procedure, I can only >> see local variables. > > > So, is it possible or not to inspect fields defined in my > TBrowserApplication? It is possible. I assume, your program contains a var Application: TBrowserApplication; For example in Chrome when paused on a breakpoint look at the right side under Watch and Breakpoints there is Scope. Under Scope there is Local and Closure. The Application should be there. Depends on where your breakpoint is.

Ahh, thank you! Now that I'm looking for it I found it in firefox (it was out of view since the area was small and there's no scrollbar until you hover over the panel, so I thought there were no more subpanels). I can inspect all the fields from there, but still I cannot find a way to show them from the console prompt (i.e. when you write a variable in the console and see its value).

Bye

Luca
Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 30 lines
El 23/9/22 a les 12:37, Mattias Gaertner via Pas2js ha escrit: > On Thu, 22 Sep 2022 15:14:48 +0000 (UTC) > Luca Olivetti via Pas2js wrote: > >> [...] >>>> Or to inspect fields in the browser debugger? >>> >>> The latter. When I put a breakpoint inside a procedure, I can only >>> see local variables. >> >> >> So, is it possible or not to inspect fields defined in my >> TBrowserApplication? > > It is possible. > I assume, your program contains a > var > Application: TBrowserApplication; > > For example in Chrome when paused on a breakpoint look at the right side > under Watch and Breakpoints there is Scope. > Under Scope there is Local and Closure. The Application should be > there. Depends on where your breakpoint is. Ahh, thank you! Now that I'm looking for it I found it in firefox (it was out of view since the area was small and there's no scrollbar until you hover over the panel, so I thought there were no more subpanels). I can inspect all the fields from there, but still I cannot find a way to show them from the console prompt (i.e. when you write a variable in the console and see its value).
I usually use simply
uses js;
Writeln(TJSJSON.stringify(yourvalue));

you can also do

uses web;
console.debug(yourvalue);

The effect is usually more or less the same.

Michael.

Luca Olivetti
to Michael Van Canneyt

El 23/9/22 a les 18:20, Michael Van Canneyt ha escrit:

Show quoted text 17 lines
> I can inspect all the fields from there, but still I cannot find a way > to show them from the console prompt (i.e. when you write a variable > in the console and see its value). I usually use simply uses js; Writeln(TJSJSON.stringify(yourvalue)); you can also do uses web; console.debug(yourvalue); The effect is usually more or less the same.

That's the old writeln trick, but you need to instrument the program to do that.
I mean how do I inspect the variables in the javascript debugger without previous instrumentation.
I now know I can do that using the "scopes" panel, but I wanted to know how I can see them in the javascript console.

By trial and error I just found that I can see them under

$mod.Application

Bye

Luca