Back

LoadScript

JS Py
Hello World

Loads a local JavaScript file asynchronously to your app to make its functionality available in your app.

app.LoadScript( path, callback? )

See Also: Script

Example - Compute the Answer to the Ultimate Question of Life, the Universe, and Everything

var scriptJS = `
var num = 7;
function computeNum() { return 6 * num; }
`
;

function OnStart() {
    app.WriteFile( "script.js", scriptJS )
    app.LoadScript( "script.js", OnLoad );
}

function OnLoad() {
    app.ShowPopup( "script.js loaded." );
    app.Alert( computeNum(), "computed number: " );
}
from native import app

scriptPJ = """
num = 7
def computeNum():
    return 6 * num
"""


def OnStart():
    app.WriteFile( "script.js", scriptPJ )
    app.LoadScript( "script.js", OnLoad )

def OnLoad():
    app.ShowPopup( "script.js loaded." )
    app.Alert( computeNum(), "computed number: " )
    Copy     Copy All       Run      
String: path to file or folder ( “/absolute/...” or “relative/...” )
Object: { isTrusted }
function( info )