DroidScript wiki

(was AndroidScript) unofficial documentation by the community

User Tools

Site Tools


sample_code:droidscript_console

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sample_code:droidscript_console [2016/09/02 19:55]
titus
sample_code:droidscript_console [2016/10/30 21:41]
105.59.166.110 DroidScript Console
Line 3: Line 3:
 Execute your droidscript commands directly from this app. Execute your droidscript commands directly from this app.
 \\ \\
-[[http://​mycode.ucoz.net/files/spk/Console_v1.spk|Here]] is the spk.+[[http://​mycode.coolpage.biz/web/spk/DroidScriptConsole_v1.spk|Here]] is the spk.
  
-<code JavaScript ​Console.js>+<code JavaScript ​DroidScriptConsole.js>
  
 +//Code By Titus
 //Called when application is started. //Called when application is started.
 function OnStart() function OnStart()
 { {
- //Create a layout with objects vertically centered. +    app.SetOrientation("​Portrait"​);​ 
- lay = app.CreateLayout( "​linear",​ "​TopCenter,​FillXY"​ );  +    app.EnableBackKey(false ); 
- +    ​//Create a layout with objects vertically centered. 
- //Create a text label and add it to layout. +    lay = app.CreateLayout("​linear",​ "​TopCenter,​FillXY"​);​ 
- txt = app.CreateText( "​Droidscript Console"​ ); +    ​lay.SetBackColor("#​000000"​);​ 
- txt.SetTextSize( ​20 ); +    //Create a text label and add it to layout. 
- lay.AddChild( txt ); +    txt = app.CreateText("​Droidscript Console", 1, 0.05, "​Center"​);​ 
- //Create Text Edit +    txt.SetBackGradient("#​999999",​ "#​555555"​);​ 
- edt = app.CreateTextEdit("​Start here: ",1,.96,"​NoSpell"​ ) +    txt.SetTextColor("#​000000"); 
- edt.SetBackColor( "#​000000"​ ); +    txt.SetTextSize(23); 
- edt.Focus();​ +    lay.AddChild(txt);​ 
- edt.SetTextSize(13 ); +    //Create Text Edit 
-        edt.SetOnEnter( clc ); +    edt = app.CreateTextEdit("​ds>: ", 1, .95, "​NoSpell"​) 
- lay.AddChild(edt);​ +    edt.SetBackColor("#​000000"​);​ 
- //Add layout to app.  +    edt.Focus();​ 
- app.AddLayout( lay );+    edt.SetTextSize(13);​ 
 +    edt.SetOnEnter(clc);​ 
 +    lay.AddChild(edt);​ 
 +    //Add layout to app.  
 +    app.AddLayout(lay);​
 } }
  
-function clc(){ +function clc() 
-var t = edt.GetText() +
-var p = edt.GetCursorPos();;​ +    var t = edt.GetText() 
-try{ +    var p = edt.GetCursorPos();;​ 
-edt.SetText(t+"​\n"​+run(t.slice(t.lastIndexOf(":"​)+1,​t.length))+"​\n"​+"​start here: " ); +    try 
-edt.SetCursorPos(t.length ); +    ​
-+        edt.SetText(t + "​\n"​ + eval(edt.GetText().slice(t.lastIndexOf(":"​) + 1, t.length)) + "​\n"​ + "ds>: "); 
-}catch(e){ +        edt.SetCursorPos(edt.GetText().length);
-edt.SetText(t+"​\n"​+e+"​\n"​+"​start here: " ​)+
-edt.SetCursorPos(t.length );+
  
-+    ​
-}+    catch (e) 
 +    { 
 +        edt.SetText(t + "​\n"​ + e + "​\n"​ + "​ds>:​ "); 
 +        edt.SetCursorPos(edt.GetText().length);​
  
-function ​run(fn) { +    } 
-  return ​new Function +    var tt = edt.GetText() 
-('return ​' ​fn)();+    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 //Get properties and methods
-function prop(objectname){ +function prop(objectname) 
-this.s =""​ +
-this.a =0 +    ​var ​s = ""​ 
- for(x in objectname){ +    ​var ​a = 0 
-    ​this.a++ +    for (x in objectname) 
-    this.s+=a+" "​+x+"​\n\n"​+objectname[x]+"​\n\n\n\n"​ +    ​
-   ​+        ​a++; 
-   ​return ​this.+        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++
 +}
 </​code>​ </​code>​
  
 [[:​|Home]]>>​[[sample_code:​|Sample Code]]\\ [[:​|Home]]>>​[[sample_code:​|Sample Code]]\\
sample_code/droidscript_console.txt · Last modified: 2016/10/30 21:41 by 105.59.166.110