DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


Sidebar

News

Version1.42 is out since December 2nd 2016


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

sample_code:droidscript_console

DroidScript Console

Execute your droidscript commands directly from this app.
Here is the spk.

DroidScriptConsole.js
//Code By Titus
//Called when application is started.
function OnStart()
{
    app.SetOrientation("Portrait");
    app.EnableBackKey(false );
    //Create a layout with objects vertically centered.
    lay = app.CreateLayout("linear", "TopCenter,FillXY");
    lay.SetBackColor("#000000");
    //Create a text label and add it to layout.
    txt = app.CreateText("Droidscript Console", 1, 0.05, "Center");
    txt.SetBackGradient("#999999", "#555555");
    txt.SetTextColor("#000000");
    txt.SetTextSize(23);
    lay.AddChild(txt);
    //Create Text Edit
    edt = app.CreateTextEdit("ds>: ", 1, .95, "NoSpell")
    edt.SetBackColor("#000000");
    edt.Focus();
    edt.SetTextSize(13);
    edt.SetOnEnter(clc);
    lay.AddChild(edt);
    //Add layout to app.	
    app.AddLayout(lay);
}
 
function clc()
{
    var t = edt.GetText()
    var p = edt.GetCursorPos();;
    try
    {
        edt.SetText(t + "\n" + eval(edt.GetText().slice(t.lastIndexOf(":") + 1, t.length)) + "\n" + "ds>: ");
        edt.SetCursorPos(edt.GetText().length);
 
    }
    catch (e)
    {
        edt.SetText(t + "\n" + e + "\n" + "ds>: ");
        edt.SetCursorPos(edt.GetText().length);
 
    }
    var tt = edt.GetText()
    tt = tt.replace(/ds>:/g, function (v)
    {
        return v.fontcolor("green")
    })
    tt = tt.replace(/ReferenceError[^\n]+/g, function (v)
    {
        return v.fontcolor("red")
    })
    tt = tt.replace(/SyntaxError[^\n]+/g, function (v)
    {
        return v.fontcolor("#ff7733")
    })
    tt = tt.replace(/TypeError[^\n]+/g, function (v)
    {
        return v.fontcolor("#779933")
    })
    tt = tt.replace(/\n/g, "<br>")
    edt.SetHtml(tt);
}
 
//Get properties and methods
function prop(objectname)
{
    var s = ""
    var a = 0
    for (x in objectname)
    {
        a++;
        s += a + " " + x + "\n\n" + objectname[x] + "\n\n\n\n"
    }
    return s
}
 
var cnt=0
function OnBack(){
setTimeout(function(){cnt=0},1000)
if(cnt==1) app.Exit();
else app.ShowPopup("Tap again to exit","Short" );
cnt++
}

Home»Sample Code

sample_code/droidscript_console.txt · Last modified: 2016/10/30 21:41 by 105.59.166.110