cumul.sml

  Download

More scripts: Vector

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
clear();  #clear console
vector Vect;
class DATABASE database;
class DBTABLEINFO tableinfo;
class DBTABLEINFO populationinfo;
numeric numPoints;
numeric index;
numeric record;
numeric numRecords;
numeric value;
numeric population;
array numeric records[1];
GetInputVector(Vect);
database = OpenVectorPointDatabase(Vect);
# Create new table
populationinfo = TableCreate(database,"Population","Created by SML script");
TableAddFieldInteger(populationinfo,"population",12);
TableAddFieldString(populationinfo,"people",16,16);
# Open old table
tableinfo = DatabaseGetTableInfo(database,"TABLE");
numPoints = NumVectorPoints(Vect);
numeric i;
for i=1 to numPoints {
	numRecords = TableReadAttachment(tableinfo,i,records,"point");
	if (numRecords <= 0) continue;
	record = records[1];
	# Write White Non Hispanic population
	value = TableReadFieldNum(tableinfo,"WhiteNonH",record);
	population = value;
	index = TableNewRecord(populationinfo,population,"WhiteNonH");
	records[1] = index;
	TableWriteAttachment(populationinfo,i,records,1);
	# Write Asian population
	value = TableReadFieldNum(tableinfo,"ASIANPOP",record);
	population += value;
	index = TableNewRecord(populationinfo,population,"Asian");
	records[1] = index;
	TableWriteAttachment(populationinfo,i,records,1);
	# Write Black population
	value = TableReadFieldNum(tableinfo,"BLKPOP",record);
	population += value;
	index = TableNewRecord(populationinfo,population,"Black");
	records[1] = index;
	TableWriteAttachment(populationinfo,i,records,1);
	# Write Hispanic population
	value = TableReadFieldNum(tableinfo,"HISPPOP",record);
	population += value;
	index = TableNewRecord(populationinfo,population,"Hispanic");
	records[1] = index;
	TableWriteAttachment(populationinfo,i,records,1);
	}
printf("Script Ran to Completion");