I would not comment on the choice of the method in itself but on one coding
aspect that could made programming much simpler. I found that building
commands as string variables and using the "run command" is quite effective.
In this case, ncols is the number of columns, a and b are strings, I
smallint. Notice there is no need to dim alias variables
a="insert into "+strTable+ " (COL1,"
b=" values ("+strTable+ ".COL1,"
for I=2 to ncols
a=a+"COL"+str$(I)
b=b+strTable+".COL"+str$(I)+","
next
a=a+obj+")"
b=b+objout+")"
a=a+b
run command a
One must be careful about the presence of blanks at the right places to
separate words (like between a and b; in my example b starts with a blank,
it could have been inserted when fusing b into a).
Jacques ("I obviously don't have a real job, I just answer questions")
Paris, Right, eh Gerald.? But please, do not let my boss know about it!
Jacques PARIS
e-mail (>>>19.12.00) [EMAIL PROTECTED]
For MapInfo support, see the Paris PC Consult enr. site at
http://www.total.net/~rparis/gisproducts.htm
For MapBasic questions see the J.Paris site at
http://www.total.net/~jakesp/index.htm
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of David M
Haycraft
Sent: January 19, 2001 9:47 PM
To: Steve Carlsson
Cc: MAPINFO-L
Subject: Re: MI-L Combined Objects
Steve
You asked
> I have a table with many polygon objects. Some of these objects have been
> combined so that even though they are geographically separate objects when
> one is selected others also select...
> So Is there a tool or procedure to go through the table an separate all
> polygons into separate objects and retain the attributes of each
object...?
This would be an interesting class exercise for a MapBasic student.
The challenge is to figure out how to "clone" the attributes for an
arbitrary table which may have up to 250 different columns of type
Char,SmallInt,Int, Float etc plus an Obj column. Clearly you need a SQL
Insert statement to insert into the table the newly-separated objects plus
their original attributes. However there doesn't seem to be any way to
create the appropriate Insert statement at run-time and execute it using
"Run Command"
The gotcha is that an SQL insert statement can either list the field values
to insert as literals or list them as variables. However, you cannot use
the "literals" variant because this cannot readily describe a complex
polyline or polygon object and you cannot use the "variables" variant
because "Run command" won't process commands containing variables!
The only solution that I ever found for this kind of problem is to resort to
the following:
dim strTable as string
dim nCols as smallInt
dim aliCol1 as alias
dim aliCol2 as alias
dim aliCol3 as alias
...
aliCol1=strTable+".Col1"
aliCol2=strTable+".Col2"
aliCol3=strTable+".Col3"
....
do case nCols
case 1 insert into strTable(COL1,OBJ)
values(aliCol1,objOut)
case 2 insert into strTable(COL1,COL2,OBJ)
values(aliCol1,aliCol2,objOut)
case 3 insert into strTable(COL1,COL2,COL3,OBJ)
values(aliCol1,aliCol2,aliCol3,objOut)
...
end case
which requires 250 column alias variables to be defined and 250 insert
statements to be spelled out explicitly.
I hope that a MapBasic guru on MAPINFO-L can point out a more elegant
solution that this :o)
By separate e-mail I'll send you a copy of a tool called disagg.mbx that
uses this method and works fine for me.
Regards
David M Haycraft
Information Analysis Associates Pty Ltd
ABN 47 085 516 105
1 Cumming Place, Wanniassa, 2903
Aust Capital Territory, Australia
Phone/Fax: 61 + 2 + 6231 8104
Mobile: 0412 001 134
Email: [EMAIL PROTECTED]
Web : www.acslink.aone.net.au/actaa/iaa.htm
A MapInfo Technology Partner
_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.
_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.