[Pas2js] Inspect variables and fields in the browser console?
Michael Van Canneyt
michael at freepascal.org
Fri Sep 23 18:20:44 CEST 2022
On Fri, 23 Sep 2022, Luca Olivetti via Pas2js wrote:
> 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 <pas2js at lists.freepascal.org> 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.
More information about the Pas2js
mailing list