Back

Script

Hello World

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

app.Script( file, noDefer )

By default it is loaded just before OnStart is being called unless you set “NoDefer” to true which forces inline loading.
This is to ensure errors are highlighted correctly in external source files.

See Also: LoadScript

Example - Deferred Loading (recommended)

app.WriteFile( "script.js", "var num = 7;\nfunction computeNum() { return 6 * num; }" );
app.Script( "script.js" );

function OnStart() {
    app.ShowPopup( "script.js loaded." );
    app.Alert( computeNum(), "computed number: " );
}
    Copy     Copy All       Run      

Example - Inline Loading

app.WriteFile( "script.js", "var num = 7;\nfunction computeNum() { return 6 * num; }" );

function OnStart() {
    app.Script( "script.js", true );

    // without noDefer true computeNum won't be defined
    app.ShowPopup( "script.js loaded." );
    app.Alert( computeNum(), "computed number: " );
}
    Copy     Copy All       Run      
Boolean: load script inline
String: path to file ( “/absolute/...” or “relative/...” )