Forums > MaxMSP

Database Problem

June 21, 2013 | 11:41 am

I have been using Andrew Brenson’s post on SQLite databases to create a database of my own.

http://cycling74.com/2008/09/05/data-collection-building-databases-using-sqlite/

I have begun to take what he has written and use it for my own. Below is a snip bit of what I am using. Everything works fine until it gets to the line of code that reads for(var i=0;i<datatypes.length;i++){+datatypes[i]+;}. In the max window it outputs: js: Hold.js: Javascript SyntaxError: missing variable name, line 41
js: source line: for(var i=0;i<datatypes.length;i++). Could you help me figure out what is going wrong?

var sqlite = new SQLite;
var result = new SQLResult;
var datatypes = ['filePath','acquiredDay','acquiredMonth','acquiredYear','acquiredHour','acquiredMiniute','acquiredSecond','locationX','locationY','locationZ','windSpeed','windDirection','barometricPressure','temperature','redLight','blueLight','greenLight','humidity','time','date','lunarCycle','rainfall'];
outlets = 2;

//open a file-based DB
function opendb(x)
{
    sqlite.open(x,1);
    get_all();
    menuLoad();
}

//setup the DB with all the necessary stuff
function build_db()
{
     exec("CREATE TABLE IF NOT EXISTS dumpster(name VARCHAR(256),filetype VARCHAR(256))");
	for(var i=0; i<datatypes.length; i++){
		add_column(datatypes[i]);
	}
}

//this outputs the entire table for the cellblock display
function get_all()
{
    exec("SELECT * FROM dumpster");
}

//insert filename and filetype
function insert_entry(){
    if(arguments.length>=2){
		exec("INSERT INTO dumpster ('"
			for(var i=0;i<datatypes.length;i++)
				{
				+datatypes[i]+;
				}
				"') VALUES ('"
			for(var i=0;i<datatypes.length;i++)
				{
				+arguments[i]+;
				}
				"')");

        //exec("INSERT INTO dumpster ('name','filetype') VALUES ('"+arguments[0]+"','"+arguments[1]+"')");
    }
    else{
        post("Wrong number of arguments");
    }
}

Viewing 1 post (of 1 total)