Recent

Author Topic: pas2js configuration help  (Read 4375 times)

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
pas2js configuration help
« on: January 16, 2019, 06:03:31 pm »
I'm just starting to play around with pas2js, but I'm running into some issues getting things configured properly, here are my steps:

- installed pas2js wtih fpcupdelux
- installed pas2jsdsgn package
- configured pas2js.cfg to point properly to source files
- file -> New -> web browser application (choose default options)
  * create initial html page
  * maintain html page
- save project to empty directory, and following structure is created

when I attempt to compile, the following error occurs "custom js file not found: "rtl.js"
I have attempted to add the "small javascript file needed" specified in this wiki: http://wiki.freepascal.org/pas2js
to the same directory as my project which does allow for compiling however, when opening in the browser and inspecting
the console window the following errors are present:
"SyntaxError: expected expression, got '<'[Learn More] project1.js:1"
"ReferenceError: rtl is not defined[Learn More]"


inspecting project1.js which is generated by compiling, I see that it has appened the rtl.js file's contents to
top of the compiled code as such
Code: Pascal  [Select][+][-]
  1. <script type="application/javascript">
  2.   rtl.run()
  3. </script>rtl.module("System",[],function () {
  4.   "use strict";
  5.   var $mod = this;
  6.   rtl.createClass($mod,"TObject",null,function () {
  7.     this.$init = function () {
   
when I clear the contents of rtl.js to be an empty script file, then compile and refresh the project1.html file the following errors occur:
"ReferenceError: rtl is not defined[Learn More] project1.js:1:1"
"ReferenceError: rtl is not defined[Learn More]"


I know I must've missed a step along the process, or am doing something wrong since it seems others have gotten pas2js to work for some time now
but any help would be appreciated.

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: pas2js configuration help
« Reply #1 on: January 16, 2019, 07:50:24 pm »
so digging around I found the rtl script here:
C:\fpcupdeluxe\ccr\pas2js-rtl\compiler\utils\pas2js\dist

I added this location to the pas2js cfg file like this, so my full cfg looks like this:

Code: Pascal  [Select][+][-]
  1. #
  2. # Minimal config file for pas2js compiler
  3. #
  4. # not yet implemented: -d is the same as #DEFINE
  5. # not yet implemented: -u is the same as #UNDEF
  6. #
  7. # Write always a nice logo ;)
  8. -l
  9.  
  10. # Display Hints, Warnings and Notes
  11. -vwnh
  12. # If you don't want so much verbosity use
  13. #-vw
  14.  
  15. -Fu$CfgDir/..\..\packages\rtl
  16. -Fu$CfgDir/..\..\packages\fcl-base
  17. -Fu$CfgDir/..\..\packages\fcl-db
  18. -Fu$CfgDir/..\..\packages\fpcunit
  19. -Fu$CfgDir/..\..\compiler\utils\pas2js\dist
  20.  
  21. #IFDEF nodejs
  22. -Jirtl.js
  23. #ENDIF
  24.  
  25. # end.


and my CfgDir is : C:\fpcupdeluxe\ccr\pas2js-rtl\bin\x86_64-win64

These steps now let me compile a web project without compiler errors and having to drop a local rtl.js file in my project folder, but loading the web page still shows rtl being undefined... not sure what else is needed?

mr-highball

  • Full Member
  • ***
  • Posts: 233
    • Highball Github
Re: pas2js configuration help
« Reply #2 on: January 16, 2019, 08:23:00 pm »
Ok.. so after doing all of the above, and starting a new project, my output .js file seems to be working appropriately, however still getting an error in the browser:
Loading failed for the <script> with source

after a little bit of looking for answers, I tried a different browser (was using firefox) and things seem to working (possible related so post: https://stackoverflow.com/questions/45879671/only-on-firefox-loading-failed-for-the-script-with-source)

I'm not sure if everything is still configured 100% properly, but perhaps my steps will help someone else.

nouzi

  • Sr. Member
  • ****
  • Posts: 296
Re: pas2js configuration help
« Reply #3 on: January 16, 2019, 10:12:30 pm »
« Last Edit: January 16, 2019, 10:52:52 pm by nouzi »
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: pas2js configuration help
« Reply #4 on: January 17, 2019, 10:40:51 am »
I've documented this rant here: http://forum.lazarus-ide.org/index.php/topic,43660.0.html
But you seem to have found the solution.

 

TinyPortal © 2005-2018