dbMakeTableRecord.sml

  Download

More scripts: Vector

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# Cindy Robbins, 17June04,  
#open vector, V
#create new polygon table, TABLE
#create integer field, F1(I, 5) in it,
#create string field, F2(s, 500) in it,
#create 10 as the first record of F1
#create "ABC" as the  first record of F2
#create 20 as the 2nd record of F1
#create "DEF" as the 2nd record of F2
#save 
#close
#end 
clear();  # clear console window
class VECTOR Vect;
class DATABASE database, db;
class DBTABLEINFO tableInfo;
class DBFIELDINFO fieldInfo;
string tablename$, fieldname1$, fieldname2$;
tablename$ = "TABLE";
fieldname1$ = "F1";
fieldname2$ = "F2";
GetInputVector(Vect);
db = OpenVectorPolyDatabase(Vect);
TableCreate(db, tablename$, "Created from SML");
tableInfo = TableGetInfo(Vect.poly.(tablename$));
tableInfo.RelatedOnly = 1;
TableAddFieldInteger(tableInfo, fieldname1$, 5 );
TableAddFieldString(tableInfo, fieldname2$, 50);
###########################################
### 1.) normal way of adding records.  
### Uncomment the following 2 lines and comment out # 2.) below
#TableNewRecord(tableInfo, 10, "ABC");
#TableNewRecord(tableInfo, 20, "DEF");
### end 1.)
###########################################
### 2.) can also add empty records and edit the fields individually too.  
### The '@' symbol indicates it is the absolute record number, which should correspond to the order the records were added.
### However, it is important to note that the absolute record # can change when you delete records.
### Comment out the following 6 lines if using 1.) above
TableNewRecord(tableInfo, 0, "");
TableNewRecord(tableInfo, 0, "");
Vect.poly.TABLE[@1].F1 =  10;
Vect.poly.TABLE[@1].F2$ =  "ABC";
Vect.poly.TABLE[@2].F1 =  20;
Vect.poly.TABLE[@2].F2$ = "DEF";
### end 2.)
###########################################
CloseVector(Vect);
print("Script completed.");