Custom js functions not found



  • Hello everyone,

    this is my first post and first of all I would like to say that BAS is amazing software, congratulations!

    My problem is: I am creating my own functions (javascript) in the item "Tools"> "Execute code".
    But my own js functions do not work when they are called within a BAS function (function created through the GUI)

    Note: "Record Mode" works normally, but in "Run Mode" an error occurs.

    See the error in "run mode":
    Success (0)
    Fails (1)
    Messages:
    1 - [948151773] ReferenceError: Can not find variable: doSomething during execution of action 948151773
    Time Spent: 00:00
    Final Message: Too Much Fails

    Some questions:
    -> Are my functions declared in the wrong place ("Tools"> "Execute code")?
    -> How to create global functions in javascript that are accessible anywhere in the script?

    See my project ...
    0_1559936007807_test-functions.xml

    Best Regards
    Thank you very much.

    BAS version: 21.8.1 (Free)
    OS version: Windows 10, x64



  • @asdbr said in Custom js functions not found:

    Hello everyone,

    this is my first post and first of all I would like to say that BAS is amazing software, congratulations!

    My problem is: I am creating my own functions (javascript) in the item "Tools"> "Execute code".
    But my own js functions do not work when they are called within a BAS function (function created through the GUI)

    Note: "Record Mode" works normally, but in "Run Mode" an error occurs.

    See the error in "run mode":
    Success (0)
    Fails (1)
    Messages:
    1 - [948151773] ReferenceError: Can not find variable: doSomething during execution of action 948151773
    Time Spent: 00:00
    Final Message: Too Much Fails

    Some questions:
    -> Are my functions declared in the wrong place ("Tools"> "Execute code")?
    -> How to create global functions in javascript that are accessible anywhere in the script?

    See my project ...
    0_1559936007807_test-functions.xml

    Best Regards
    Thank you very much.

    BAS version: 21.8.1 (Free)
    OS version: Windows 10, x64

    The OnApplicationStart function is executed separately before all threads start; you can transfer data from it through global variables or resources:

    0_1560022907544_65539e5b-5399-480c-8030-672f656dbcca-изображение.png
    0_1560022927668_1559935942195-test-functions.xml



  • @fox

    Hello, thanks for the answer

    The problem is the project works well only "Record Mode", but dont in "Run Mode".
    Transfer my custom js function to OnApplicationStart does not solve the problem.

    Record mode
    0_1560379826858_Capturar1.JPG
    Run mode
    1_1560379826867_Capturar2.JPG

    I believe this is a bug. I'm thinking how to solve it, I would like to run my scripts in "run mode" too.
    Thanks!



  • I discovered what happens: I need to load at least one url before loading the custom js functions. I loaded http://example.com before the custom js functions worked fine in "Run Mode".

    So simple...
    Thank you all


Log in to reply
 

  • 3
  • 2
  • 2
  • 3
  • 2
  • 2
  • 5
  • 7