strdef cmdstr, cmdstr1, pre_type, post_type
objref f2c

proc conn_cells() {local num, wgt, syn
	for i=0, numCellTypes-1 {
		sprint(cmdstr, "%s_idx = %g", cellType[i].cellType_string, i)
		{execute1(cmdstr)}
		cellType[i].numConns = new Vector(numCellTypes)
		cellType[i].numSyns = new Vector(numCellTypes)
		cellType[i].wgtConns = new Vector(numCellTypes)
	}

	// load file
	f2c = new File()
	sprint(cmdstr, "../datasets/conndata_%g.dat", ConnData)
	f2c.ropen(cmdstr)		// Open the celltype
	connData = f2c.scanvar
	for r=0,connData-1 {
		f2c.scanstr(pre_type)
		f2c.scanstr(post_type)
		wgt = f2c.scanvar
		num = f2c.scanvar
		syn = f2c.scanvar

		sprint(cmdstr, "%s_idx", pre_type)
		sprint(cmdstr1, "%s_idx", post_type)
		if ((name_declared(cmdstr) > 0) && (name_declared(cmdstr1) > 0)) {
			sprint(cmdstr, "if ((strcmp(pre_type,\"granulecell\")==0) && (strcmp(post_type,\"granulecell\")==0)) {num = percentSprouting/100*cellType[%s_idx].numCells*cellType[%s_idx].numCells}", pre_type, post_type)
			{execute1(cmdstr)}

			sprint(cmdstr, "cellType[%s_idx].numConns.x[%s_idx] = %f", pre_type, post_type, num)
			{execute1(cmdstr)}
			
			sprint(cmdstr, "cellType[%s_idx].numSyns.x[%s_idx] = %f", pre_type, post_type, syn)
			{execute1(cmdstr)}
			
			sprint(cmdstr, "cellType[%s_idx].wgtConns.x[%s_idx] = %f", pre_type, post_type, wgt)
			{execute1(cmdstr)}
		}
	}
	f2c.close()
}
conn_cells()