Create Table and add User Entered variables

96 views
Skip to first unread message

Rosario C

unread,
Feb 5, 2012, 5:06:03 PM2/5/12
to MapInfo-L
I'm looking to create an on the fly table, after a user enters 4
values


Include "MapBasic.def"

Dim SiteSector as String
Dim Latitude, Longitude as Float
Dim P_N as Integer

Dialog
Title "PN Checker"

Control StaticText
Title "Enter Cascade Sector:"
Position 5,10
Control EditText
Into SiteSector

Control StaticText
Title "Enter Latitude:"
Position 10,25
Control EditText
Position 82,25
Into Latitude

Control StaticText
Title "Enter Longitude:"
Position 10,40
Control EditText
Position 82,40
Into Longitude

Control StaticText
Title "Enter P_N Value:"
Position 10,55
Control EditText
Position 82,55
Into P_N

Control OKButton '
Control CancelButton

After pressing Ok, i'd like to create a table "P_N_TEMP" with 4
columns, and then have the table updated with the variables entered in
the dialog box. Then create a point, doesnt matter for now, and have
it added to a known window id.

Create Table P_N_TEMP
( SiteSector Char(15),
Long Float,
Lat Float,
P_N Integer)
Type Native


any help is very much appreciated..please

thanks.

RC

Glen

unread,
Feb 6, 2012, 10:27:46 PM2/6/12
to MapInfo-L
that command creates the table

now you must insert the data


taken from the mapbasic manual


Description
The Insert statement inserts new rows into an open table. There are
two main forms of this
statement, allowing you to either add one row at a time, or insert
groups of rows from another table
(via the Select clause). In either case, the number of column values
inserted must match the
number of columns in the column list. If no column list is specified,
all fields are assumed. Note that
you must use a Commit Table statement if you want to permanently save
newly-inserted records to
disk.
If you know exactly how many columns are in the table you are
modifying, and if you have values to
store in each of those columns, then you do not need to specify the
optional columnlist clause.
In the following example, we know that the table has four columns
(Name, Address, City, and State),
and we provide MapBasic with a value for each of those columns.
Insert Into customers
Values ("Mary Ryan", "23 Main St", "Dallas", "TX")
The preceding statement would generate an error at run-time if it
turned out that the table had fewer
than (or more than) four columns. In cases where you do not know
exactly how many columns are in
a table or the exact order in which the columns appear, you should use
the optional columnlist
clause.
Examples
The following example inserts a new row into the customer table, while
providing only one column
value for the new row; thus, all other columns in the new row will
initially be blank. Here, the one
value specified by the Values clause will be stored in the “Name”
column, regardless of how many
columns are in the table, and regardless of the position of the “Name”
column in the table structure.
Insert Into customers (Name)
Values ("Steve Harris")
The following statement creates a point object and inserts the object
into a new row of the Sites
table. Note that Obj is a special column name representing the table's
graphical objects.
Insert Into sites (Obj)
Values ( CreatePoint(-73.5, 42.8) )

Rosario C

unread,
Feb 8, 2012, 4:37:13 PM2/8/12
to MapInfo-L
Glen,

Thank you for your help..

The one thing I'm still having difficulty with is when i insert
values in the first row, which has lat/long values, can i create a
point based on the one row only, because when i do an insert (obj)
values (createpoint(lat, long)) it adds another row, with no
information. so when i select the point for information, its blank.

ty
Message has been deleted

Glen

unread,
Feb 8, 2012, 7:59:48 PM2/8/12
to MapInfo-L
you need to add an object to your create table

Create Table P_N_TEMP ( SiteSector Char(15), Long Float, Lat Float,
P_N Integer, point object) Type Native


Insert Into Table P_N_TEMP ( SiteSector ,Long , Lat , P_N Integer,
obj) Values (SiteSector ,Long , Lat , P_N , createpoint(long,lat))

you need to check the syntax but some thing like this

Reply all
Reply to author
Forward
0 new messages