//function called after startin the app to process the grades
function processMark(results)
{
var s = 0; //The grade variable
var nte = 0; //How much it counts
var len = results.rows.length; //Lenght of the database
var txt = ""; //Troubleshoot stuff
for(var i = 0; i < len; i++ )
{
var item = results.rows.item(i); //Loading stuff out of the database
ttt.SetText( item.data_Bol ); //It doesn't work if I put "item.data_Bol" directly in the if statment (bug I think) so I put it in some invisible text and get it from there.
txt+=item.data_Bol; //Troubleshoot stuff
txt+=" "; //Troubleshoot stuff
if( ttt.GetText() ){ //If does always turn true or false never mixed->(what I want it to do!!)
s += item.data_Val*=item.data_Num; //Calculation stuff
nte += item.data_Num; //Calculation stuff
}
}
app.ShowPopup( txt ); //Troubleshoot stuff
s /= nte; //Calculation again
mark.SetText( Math.round( s*2 )/2 ); //Set some text to the calculated stuff
}
//And here's the database
db = app.OpenDatabase( "Note" );
db.ExecuteSql( "CREATE TABLE IF NOT EXISTS noten " +
"(id integer primary key, data text, data_Name text, data_Val integer, data_Num integer, data_Fach text, data_Bol bolean)" );