Menu

const and vars not included when using loadScript()

devnull
2024-01-20
2024-01-22
  • devnull

    devnull - 2024-01-20

    I want to move parts of my code into external js-files and include them using
    scriptThread.loadScript(...);

    For functions this works pretty well, but not for things outside functions like const, var/let definitions. They are not exported to the main function, nor useable within the script where they are defined.

    More worse, when i define a const in the main script, it is not useable within a function in an loaded script.

    Is this per design, or is it a bug?

     

    Last edit: devnull 2024-01-20
  • Stefan Zieker

    Stefan Zieker - 2024-01-22

    It is bug. It worked when I used the old Qt script interpreter (Qt 5.14.2). I migrated to Qt 6.4.3 a few month ago. This version has a new interpeter.
    I will look into it when I have time. Thx for reporting this.

     
  • devnull

    devnull - 2024-01-22

    Way cool, great job pal! Glad to get the product better. Until then i just move the parts back into the main script, so no hurry needed.

     
  • devnull

    devnull - 2024-01-22

    You should also check for non-existant functions. If you just call an unknown funciton in the code (e.g. "foo();") and that function does not exist (or just misspelled) the code execution also freezes.

     
  • Stefan Zieker

    Stefan Zieker - 2024-01-22

    Which version of ScriptCommunictor do you use and on which which platform (Linux, Windows or MacOs) do you use it?
    I added foo() to a script and ScriptCommunictor showed an error and the script was stoped (that's how it should be).

     

    Last edit: Stefan Zieker 2024-01-22

Anonymous
Anonymous

Add attachments
Cancel