I'm starting to use Google App Scripts, and with the little I know of JavaScript I tried the following below. I get an error, but the script does seem to be working.
Why does it give an error? It seems that it is specifically looking to run a function when I press the little play button.. Would it be bad practice to structure a google app scripts doc as I have done below?
(function (id) {
var sheet = SpreadsheetApp.openById(id).getSheets()[0];
var data = sheet.getDataRange().getValues();
Logger.log(data);
sheet.appendRow(['this','is','another', 'bigger','test','of','stuff']);
})('1BXDicksYS19jre0tZKHEjqqyvdzbhbtFfSm053q2sZ0')
=== EDIT ===
Google Apps Scripts shouldn't be run from an IIFE, since it wants to explicityly trigger a function. So yes. I think, in my still limited experience a year later, that this would be a poor way to write a Google Apps Script.
function myFunction() { var id='xxxxx'; etc; }then it will appear in the functions list and can be used in triggers