Sign in Join

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

Mailing lists / pas2js / 2022-08

htmlwidget in pas2j 2.2.0: pas.JS.isUndefined is not a function

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Luca Olivetti

As per the subject, I'm using pas2js 2.2.0 with fpc 3.2.2 and lazarus 2.2.2.

Since I had problems with Pas2JS_Widget, I'm now back to the basics following this article:

https://www.freepascal.org/~michael/articles/pas2js1/pas2js1.pdf

and while the first method (page 12, plain javascript classes) works, if I try to use the second one (using the httpwidget unit, not the webwidget one as the article says) I get this error in firefox:

Uncaught TypeError: pas.JS.isUndefined is not a function EventEntry webwidget.pas:2640
cb rtl.js:256
cb rtl.js:256
HookupEvent webwidget.pas:2665
AddEvent webwidget.pas:2690
SetHTMLEvent webwidget.pas:2477
DoRun login.lpr:27
Run custapp.pas:206
$main login.lpr:62
run rtl.js:141
<anonymous> login.html:51
webwidget.pas:2640:10

Bye

Luca

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 25 lines
As per the subject, I'm using pas2js 2.2.0 with fpc 3.2.2 and lazarus 2.2.2. Since I had problems with Pas2JS_Widget, I'm now back to the basics following this article: https://www.freepascal.org/~michael/articles/pas2js1/pas2js1.pdf and while the first method (page 12, plain javascript classes) works, if I try to use the second one (using the httpwidget unit, not the webwidget one as the article says) I get this error in firefox: Uncaught TypeError: pas.JS.isUndefined is not a function EventEntry webwidget.pas:2640 cb rtl.js:256 cb rtl.js:256 HookupEvent webwidget.pas:2665 AddEvent webwidget.pas:2690 SetHTMLEvent webwidget.pas:2477 DoRun login.lpr:27 Run custapp.pas:206 $main login.lpr:62 run rtl.js:141 <anonymous> login.html:51 webwidget.pas:2640:10

very strange, it works here. if I look in the Javascript, I can see the function.

Can you look in the generated .js file, you should see something like:

   this.isUndefined = function (v) {
     return v == undefined;
   };
   this.isDefined = function (v) {
     return !(v == undefined);
   };

Are you using optimizations ? If so, please try adding -O- in the custom options of the compiler.

Michael.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 29/8/22 a les 14:11, Michael Van Canneyt ha escrit:

Show quoted text 42 lines
On Mon, 29 Aug 2022, Luca Olivetti wrote: > As per the subject, I'm using pas2js 2.2.0 with fpc 3.2.2 and lazarus > 2.2.2. > > Since I had problems with Pas2JS_Widget, I'm now back to the basics > following this article: > > https://www.freepascal.org/~michael/articles/pas2js1/pas2js1.pdf > > and while the first method (page 12, plain javascript classes) works, > if I try to use the second one (using the httpwidget unit, not the > webwidget one as the article says) I get this error in firefox: > > > Uncaught TypeError: pas.JS.isUndefined is not a function > ?? EventEntry webwidget.pas:2640 > ?? cb rtl.js:256 > ?? cb rtl.js:256 > ?? HookupEvent webwidget.pas:2665 > ?? AddEvent webwidget.pas:2690 > ?? SetHTMLEvent webwidget.pas:2477 > ?? DoRun login.lpr:27 > ?? Run custapp.pas:206 > ?? $main login.lpr:62 > ?? run rtl.js:141 > ?? <anonymous> login.html:51 > webwidget.pas:2640:10 very strange, it works here. if I look in the Javascript, I can see the function. Can you look in the generated .js file, you should see something like: ? this.isUndefined = function (v) { ??? return v == undefined; ? }; ? this.isDefined = function (v) { ??? return !(v == undefined); ? };

Yes, the snippet is there

Are you using optimizations ? If so, please try adding -O- in the custom options of the compiler.

Same error (plus 3 warnings "unreachable code after return statement")

Bye

Luca

Reply by email

Luca Olivetti
to Luca Olivetti

El 29/8/22 a les 14:22, Luca Olivetti ha escrit:

Show quoted text 20 lines
> > very strange, it works here. if I look in the Javascript, I can see the > function. > > Can you look in the generated .js file, you should see something like: > > ?? this.isUndefined = function (v) { > ???? return v == undefined; > ?? }; > ?? this.isDefined = function (v) { > ???? return !(v == undefined); > ?? }; Yes, the snippet is there > > Are you using optimizations ? If so, please try adding -O- in the custom > options of the compiler. Same error (plus 3 warnings "unreachable code after return statement")

It was a PEBKAC: when I pasted the html code from the article, I left the original one generated by lazarus :-(

Bye

Luca

Reply by email

Luca Olivetti
to Luca Olivetti

El 29/8/22 a les 14:33, Luca Olivetti ha escrit:

It was a PEBKAC: when I pasted the html code from the article, I left the original one generated by lazarus :-(

Speaking of which (the article), could you send me the code of part 2 "Communicating with the webserver"?

TIA

Bye

Luca

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 7 lines
El 29/8/22 a les 14:33, Luca Olivetti ha escrit: > It was a PEBKAC: when I pasted the html code from the article, I left the > original one generated by lazarus :-( Speaking of which (the article), could you send me the code of part 2 "Communicating with the webserver"?

Code sent in a private mail...

Michael.

Reply by email