User Tools

Site Tools


Privacy Policy


Version 2.50 is out since Jan 1st 2022

Frequently Asked Questions


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


Decimal Values in a Textedit

(Sample code by Steve Garman posted in the DroidScript Google Group)

Please note that this sample does not allow negative numbers but it does allow more than 1 dot, so the string will still need to be checked later to see if it is a valid number. You can look at this sample too.

//Called when application is started.
function OnStart()
    //Create a layout with objects vertically centered.
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );    
    //Create a text label and add it to layout.
    txt = app.CreateTextEdit( "",-1,-1,"Number" );
    txt.SetOnChange( txtOnChange );
    lay.AddChild( txt );
    //Add layout to app.    
    app.AddLayout( lay );
function txtOnChange()
   var s1 = this.GetText();
   var s2 = s1.replace(/[^0-9\.]/g, "");
   if(s1 != s2)
      this.lastPos = this.GetCursorPos();
sample_code/decimal_input.txt · Last modified: 2015/03/04 00:02 (external edit)