User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

built_in:load_script

app.LoadScript(url[, callback])

url (required) is an absolute or relative path to the script or script library you want to load into your project at runtime.

if you want your script loaded from on your Users' devices, a relative path below your project's path is generally needed.

E.g. app.LoadScript(“js/myScript.js”);

You could have a required project app that does nothing but place your shared libraries on Users' devices in a common location, so your other apps could share them.

You'd need to check for your library existance, and version number, in your other app(s) and prompt the User to update your libraries from PlayStore if they hadn't already.

If your LoadScript()ed libraries were not in a directory under your project, but directly on the SDcard as just described, you would need to use an absolute (full) path to the location where your script(s) resided.

Something like -

var libraryLocationPath = “/storage/emulated/0/myAppProjectsLibrary/”; if (app.FileExists(libraryLocationPath + “manifestVersionInfoEtc.js”)){ app.LoadScript(libraryLocationPath + “manifestVersionInfoEtc.js”); }else{ take steps with User to download (fresh) libraries } Although you could easily achieve it, some Users might not like you directly downloading and installing files onto their device from web addresses unkown to them, and may prefer the PlayStore approach. The second argument in LoadScript() is callback. LoadScript defers loading of scripts in effect until until the app event OnStart() is fired. callback - is an optional function you can write yourself to handle any processing you want done as the library completes loading. Note: as LoadScript defers loading like this, you can not use anything it is loading until the app's OnStart() event fires. If you really really need something you don't want in, or can't embed in your main script, and it is small enough not to slow your app's initial loading down, and you are putting the script in a folder under your project, or local absolute path, then if it is crucial to you to have it before OnStart(), you might consider using:— var myObject = app.ReadFile(“lib/myObject.js”); authenticate the file by a means known to you, if so, then … myObject = eval(myObject);

PAN

built_in/load_script.txt · Last modified: 2015/11/09 16:13 (external edit)