Well, it's a project for my master degree in strength and conditioning. I have to develop an application which provide a training session based on personal time record at running. I use AppInventor because predecessors have started on it.
So, when the athlete use the app, they enter their records. These values are sending on the googlesheet thanks to the script. On this GS calculations are made including the solver. Then he reads the values obtained by the solver and write them in the app. Finally, a training session will be created thanks to these special values from the solver.
function doGet(e) {
// ### Write INPUT to A1 to M1 on Sheet2 ###
if(e.parameter.func == "WRITE") {
var ss = SpreadsheetApp.getActive();
var sh = ss. getSheetByName("Sheet2");
sh.clearContents();
sh.appendRow([e.parameter.a1,e.parameter.a2,e.parameter.a3,e.parameter.a4,e.parameter.a5,e.parameter.a6,e.parameter.a7,e.parameter.a8,e.parameter.a9,e.parameter.a10,e.parameter.a11,e.parameter.a12,e.parameter.a13,e.parameter.a14,e.parameter.a15]);
return ContentService.createTextOutput("Data Successfully Written");
}
// ### Read OUTPUT from C2 to C8 on Sheet1 ###
else if(e.parameter.func == "READ") {
var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName("Sheet1");
var rg = sh.getRange("C2:C8").getValues();
var outString = [];
for(var row=0; row<9 ; ++row){
outString.push(rg[row]);
}
return ContentService.createTextOutput(outString); // will return a1,a2,a3,a4,a5
//return ContentService.createTextOutput(JSON.stringify(outString)); // will return [[a1],[a2],[a3],[a4],[a5]]
}
}
And the screenshot of the Ai2, to show you the link between the script and the app.