Sign in Join

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

Mailing lists / pas2js / 2020-12

Call functions from other JS file

23 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

Michael Van Canneyt
to imperyal: Probably a very basic thing... How can I call a function defined on pascal, from normal…
imperyal wrote
Hello, Probably a very basic thing... How can I call a function defined on pascal, from normal js code?

First, the rtl.run() fnuction must have been called exactly once. This does some housekeeping, for example it runs the initialization section. After this, the pascal functions are available as

pas.unitname.functionname.

So for example

pas.SysUtils.UpperCase()

You can also call functions defined in the main program: pas.program.yourfunc()

or run the main program again:

pas.program.$main()

One of the thngs on the roadmap is lobrary support and Javascipt modules, this will make things simpler.

but for the moment, the above will work.

Michael

Reply by email

Michael Van Canneyt
to imperyal
imperyal wrote
Thank you Michael Van Canneyt, it works as expected. Support for Libraries and Modules would be great.

Yes, I know :-)

I'm trying to use VUE with pas2js, any suggestions on how to do that? The idea is to use pas2js for the business logic (we already have most of it done in Pascal), and VUE for the user interface. Components would allow that easily...

Well, interesting question.

Vue.js is on my todo list. I found some articles on how to use vue with 'plain' javascript, i.e. without use of webpack and the whole ecosystem that this implies, but I didn't get around to making a demo app.

So at this point, I can only say that I have plans for it, but nothing concrete.

Michael.

Reply by email

Mgr. Janusz Chmiel
to Michael Van Canneyt: Yes, I know :-) Well, interesting question. Vue.js is on my todo list. I found some…

Dear experienced professionals here,
I Am heavily fightighting where to place if then block and I Am having troubles with begin and End commands where to place them. If somebody of us would have The time, please write The repaired functioning source file to Me. Thank you very very much.
Understanding where to ut if then block is still my biggest pain while coding in Object Pascal. So I AM very sorry to all of us, who are experienced experts here.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201215/5e5c2f9d/attachment.htm> -------------- next part -------------- A non-text attachment was scrubbed... Name: demohtmlwidgets.pp Type: application/octet-stream Size: 2973 bytes Desc: not available URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201215/5e5c2f9d/attachment.obj>

Reply by email

Mgr. Janusz Chmiel
to Mgr. Janusz Chmiel

I would like to publicly thank to MR Wancare for this ssource file. If somebody will help Me with if then condition, I will be able to construct various questionaires with table. Sadly it is true, that without help of mailing list members, I would never been able to create functioning fact is, that even MR Wancare has helped Me so much, I Am having even problems with so simple if then block. It will be really The last plea and I will have to sadly accept The fact, that I Am too stupid to understand source code structure of object Pascal. I AM very sorry, that I AM intruding you. I Am aware, that many of us have complex programmers jobs and that my ideas are not very interesting for us. It will be really my last plea and thank all of you, who are having someempathy and patience with Me. Mr Wancare, thank you for yours programmers work, which you are investing so yours coded units can bring so many Pascal developers The feeling of happyness and joy.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201215/42dc4503/attachment.htm>

Reply by email

Jean SUZINEAU
to Mgr. Janusz Chmiel

I can't test your code  but it seems you have an extra pair of begin/end after implementation of method

function TEventTableWidgetDemo.useranswercorrect(aIndex : Integer) : Boolean;

I join the fixed file.

Le 15/12/2020 à 21:55, Mgr. Janusz Chmiel a écrit :

Show quoted text 37 lines
I would like to publicly thank to MR Wancare for this ssource file. If somebody will help Me with if then condition, I will be able to construct various questionaires with table. Sadly it is true, that without help of mailing list members, I would never been able to create functioning app at all. Sad fact is, that even MR Wancare has helped Me so much, I Am having even problems with so simple if then block. It will be really The last plea and I will have to sadly accept The fact, that I Am too stupid to understand source code structure of object Pascal. I AM very sorry, that I AM intruding you. I Am aware, that many of us have complex programmers jobs and that my ideas are not very interesting for us. It will be really my last plea and thank all of you, who are having someempathy and patience with Me. Mr Wancare, thank you for yours programmers work, which you are investing so yours coded units can bring so many Pascal developers The feeling of happyness and joy. ------------------------------------------------------------------------ Logo AVG <http://www.avg.com/internet-security> Tento e-mail byl zkontrolován na viry antivirovým softwarem AVG. www.avg.com <http://www.avg.com/internet-security> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> _______________________________________________ Pas2js maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201215/46fadaac/attachment-0001.htm> -------------- next part --------------
A non-text attachment was scrubbed...
Name: demohtmlwidgets.pp
Type: application/x-wine-extension-pp
Size: 2959 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201215/46fadaac/attachment-0001.bin>

Reply by email

Mgr. Janusz Chmiel
to Jean SUZINEAU

Dear Jean,
Yours attempt have been partially successfull. But I AM getting new error. And this is my reason of my deep sadness. Where to put The if and then block. demohtmlwidgets.pp(82,26) Error: Instance member "useranswercorrect" inaccessible here

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201215/ae139f4a/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to heliosroots

Dear Helios,
Thank you for yours correct advice. Really, compiler is working and code have been converted to Javascript successfully. But console do not contain output generated by writeln procedure. Sure, I have console output enabled inside main demos form. So The question is, when if then condition block will be really executed. If this condition block resides inside body of function. Should I call The function elsewhere in some part of The source so condition block will be realized after function execution? So I Am thinkink. If should I declare some other boolean type variable and type for example. Ff := TEventTableWidgetDemo.useranswercorrect();
To be sure, that condition block will be really executed. And that writeln will write its output to The console. Sure. My desire was to have blue coloured column, but I do not want to overload others so much so I only want to have functioning condition block.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201216/e341804b/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to Mgr. Janusz Chmiel

Because I want to have background routine, which will automatically check all input fields and if The answer will be correct, function will evaluate The result. The freedom of this approach is The two facts. Users do not have to Press Enter or confirm every answers by clicking on some buttons
2. Users have their full freedom to choose, which answer will be answerred and on which order.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201216/0ab77172/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to heliosroots

Unfortunately, code not react on good answer. Very probably, because it is necessary to create some event detection which will intercept all input fields. YOurs code is goodly thinked, unfortunately creating code, which monitor automatically changes of editable fields requires some events. But thank you for yours time. Writeln do not display output, and colours are still very Azure blue. According to my screen reader, which is capable to detect colour by calling Browser object model.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201216/805093ba/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to heliosroots

My goal is to prepare several online memory based tests based on various questionaires. Those online interactive forms with questions are very good for all people, who would train their memory. Especially acters are very often remembered by a older people, because TV was very often a part of their lifes. Sure. Pictures of The acters would be better, but I do not see and there would be A copyright issue. But names, first names and sur names are not illegal. And because Microsoft is so generous corporation, I would like to host The pages and sources on Github. Because my brain is not so smart, I would only be able to extend The code of somebody else by adding various questions and answers by using copy and paste operations and text editing. I know, not very good idea, because it would be much more better, if I would simply create my own code from scratch. So I Am writing you A right.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201216/3eb28a0f/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to heliosroots

I have previously used questionaires based on The code from MR Jean Suzieau. The code has disadvantage, that if there was more than 20 questions, all editable fields were not clickable on Tablet with Android, if browser have used Android Webview module to interpret WEB content. When I have tried special table demo from MR Wancare, i have been very nicely impressed by The fact, that may be, even long table could be used with more than 20 questions.

I know, that questions could be also stored as A line of text. My goal is so resulting questionaires would be acceptable for sighted majority. Because some times, screen readers do not report something apppropriate, but real screen content is not very pleasant to see. It is sad, that I could program perfectly in Pascal 3.0 from 1985 but finding out where to add some condition in The modern code is not easy for Met to understand. May be, that somebody of us could tell Me, if it would not be easier to use Google forms service to construct such questionaires instead intruding developers on this mailing list. But it is so nice feeling, when code can react on multiple input field on The background.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201216/b6ac70c7/attachment.htm>

Reply by email

Mgr. Janusz Chmiel
to Mgr. Janusz Chmiel: I have previously used questionaires based on The code from MR Jean Suzieau. The code has…

I have found out to The very realistic conclusion. I will be patiently waiting for The unit of MR Helios. When he will publicly made it available. Because for my needs, I do not need to much various GUi elements on WEB form. And I will begin from scratch myself without bothering others and I will be able to be proud on yourself that I Am not only copy paste programmer, but that I really code myself from scratch with my own even not so smart and professional approach. In other case, I would never learn programming. I would become not very popular modifiers of codes which have been created by some one else. And this approach is not only non ethical but also not smart to The complex work of others.I have deeply thought about my approach to programming. Creative work is The most needed. So I must really learn and I must be creative, I can not become slightly code modifier by using others work. So thank all of you with The patience with Me.

Tento e-mail byl zkontrolován na viry programem AVG. http://www.avg.cz -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20201217/7e7371f9/attachment.htm>

Reply by email