DroidScript unexpected end of token

253 Views Asked by At

It says exactly this. I don't think I made a mistake. Here is my code:

function OnStart()
{
 list=app.LoadText("List");
lvw= app.CreateListView(list,"Lego");
 
 lvw.SetOnTouch( lvw_OnTouch );
 lvw.Show();
 }
 app.EnableBackKey( "false" );

 function lvw_OnTouch( item )
 {
if(item=="Add Item"){
to=app.LoadText( "List" );
//Create dialog window.
dlgTxt = app.CreateDialog( "Add Item" );  
//Create a layout for dialog.
layDlg = app.CreateLayout( "linear", "vertical,fillxy,left" );
layDlg.SetPadding( 0.02, 0, 0.02, 
 0.02 );
dlgTxt.AddLayout( layDlg );
lstDlg = app.CreateTextEdit("");
lstDlg.SetHint( "*******Item ID  here*******" );
lstDlg.SetPadding( 0.0, 0, 0.02, 
0.02);
lstDlg.SetTextColor( "#dddddd" );
layDlg.AddChild( lstDlg );
lstDlg.SetOnEnter( enter );
 amount= app.CreateTextEdit("");
amount.SetHint( "*******Item Amount*******" );
amount.SetPadding( 0.0, 0, 0.02, 
0.02);
amount.SetTextColor( "#dddddd" );

layDlg.AddChild( amount);
amount.SetOnEnter( enter );
//Show dialog.
dlgTxt.Show();
}else if(item=="Reset"){
var yesno=app.CreateYesNoDialog("Do you really want to reset?");
yesno.SetOnTouch(yesnores);
yesno.Show();

}else if(item=="Exit App"){
app.Exit(  );
}else{
lvw.Show();
}
function enter()
{
dlgTxt.Hide();
lvw.Show();
app.SaveText("List",to+","+lstDlg.GetText()+"        "+amount.GetText());
}
function OnBack()
{
app.Exit(  );
}
function yesnores(result)
{
if(result=="Yes") 
{app.SaveText("List","Add 
Item,Reset,Exit App");
}else  lvw.Show();
}
}

I checked the code again and again but no result, I can't find what causes the error. Don't forget that is not javascript, that is DroidScript, that is different from javascript. The app needs to hold values they are coming from user when user hits Add Item, the list should be resetten when user presses Reset and the user should exit from the app with just one click to Exit App.

2

There are 2 best solutions below

0
Steve Garman On BEST ANSWER

You have a line break in the middle of a string

This should be all one line

app.SaveText("List","Add Item,Reset,Exit App");
1
Luiz Bruno R.T. On

click on debug check what is happening it shows her the problem that is occurring