create.sml

  Download

More scripts: Vector

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
##################################################################
#
#	Sample SML Script which shows how to create a database table
#	and set it to be related to another table
#
#
vector Vect;
class DATABASE db;
class DBTABLEINFO tinfo;
class DBFIELDINFO finfo, keyfinfo;
string tablename$ = "SML1";			# This is the name we'll use for the table
string fieldname$ = "field";		# This is the name we'll use for the field
GetInputVector(Vect);
#----------------------------------------------------------
# Get the handle for the polygon database
db = OpenVectorPolyDatabase(Vect);
#----------------------------------------------------------
# Create a table named SML1
TableCreate(db, tablename$, "Created from SML");
#----------------------------------------------------------
# Get the info for this table.
tinfo = TableGetInfo(Vect.poly.(tablename$));
#----------------------------------------------------------
# Make the table Related Only
tinfo.RelatedOnly = 1;
#----------------------------------------------------------
# Add a 40 character wide string field.
#	Note that Vect.poly.(tablename$) is the same as sayig
#	Vect.poly.SML1 but lets us use a variable to select the
TableAddFieldString(Vect.poly.(tablename$), fieldname$, 40);
#----------------------------------------------------------
# Get the field infos of the Primary key and the field we 
# just created
finfo = FieldGetInfoByName(Vect.poly.(tablename$), fieldname$);
keyfinfo = FieldGetInfoByName(Vect.poly.CLASS, "Class");
#----------------------------------------------------------
# Make the field we just created a point to the primary key
finfo.Key = keyfinfo;