Hi Folks,
What I have managed to do here is to create a code and save it into a .WOR so it is
automatically performed upon workspace opening...
The code asks for a selection (SQL Query) to be buffered upon (with a 100 metre
buffer). The buffer is then saved to a table and opened as a table. MI then selects
all the cadastral records where the cadastral.obj intersects with the buffer.obj and
saves these records to a table.
The code is as follows:
!-----------------------------------------------------------------------
!Stretch's case query code ahead
!-----------------------------------------------------------------------
!New buffer table to add to Workspace
Open Table "G:\DEPT\Dengue\CachedAccess\autobuft" As autobuft Interactive
!Select case properties from cadastral layer
Select * from ACQ_DateOfLastConfirmed_Primary, CCC_Property_Details where
CCC_Property_Details.Lot_Plan =
ACQ_DateOfLastConfirmed_Primary.Lot_plan into Selection
!Get the selected object
DIM objPoly AS OBJECT
Create Object As Buffer
From Selection
Into Variable objPoly
Width 100 Units "m"
!Insert Buffer into Table
INSERT INTO autobuft (obj) VALUES (objPoly)
!Open Buffer Table and display with 2point red line in top layer of map window
set map redraw off
Add Map Layer autobuft
Set Map Layer 1 Display Global Editable Off Selectable On Global Line (1,2,0) Global
Pen (30,2,16711680) Global Brush
(1,16777215,16777215) Global Symbol (105,12582912,24,"MapInfo Miscellaneous",0,0)
Global Font ("Arial",0,9,0) Zoom (0,
100000) Units "km" Off Label Line None Position Center Font ("Arial",0,9,0) Pen
(1,2,0) With parcel_type Parallel On Auto
Off Overlap Off PartialSegments Off Duplicates On Offset 2 Max Visibility On Nodes Off
Arrows Off Centroids Off
set map redraw on
!Select Premises within Buffer Area and Create WorkZone Table
Select * from CCC_Property_Details, autobuft where autobuft.Obj Intersects
CCC_Property_Details.Obj into WorkZone
Close Table Query1 Interactive
!-------------------------------------------------------------------
!End of Stretch's case query code
!-------------------------------------------------------------------
Thanks particularly to Brad Peppler @ MapInfo Australia, Greg Driver @ Surrey Police
(UK), Jacques Paris ([EMAIL PROTECTED]) and Darrin Clement.
Some of the feedback I recieved included:
"I have the feeling that table and column names or aliases are restricted to 32
characters, and that spaces are not allowed. The error line number refers to where the
error was encountered, not necessarily where the code was in error; i.e. some
definition can be given in line 10 and an error resulting from that definition be felt
only in line 20 because it was only in line 20 that a conflict due to the definition
will arise.
When you open a table such as "TrialAutoCasesToBufferForBufferTable1.TAB"
you can notice that the wor truncates its table name to
"TrialAutoCasesToBufferForBuffe"
Could it be possible that at some other places in the wor there could be some similar
truncations that will give confusing results?
Would the same 32-char restriction apply when committing tables?
I have gotten into troubles while creating tables with automatic names derived from an
open table name by the addition of a "_XYZ" that would exceed the 32 char limit. Total
confusion resulted from that.
I will advise you to review all your table naming in light of that.
Jacques Paris"
and
"The ":309" is indeed the line in the workspace that is
registering a problem. Note that sometimes it is the line
cited, other times it is line before. So in this case, open
your workspace in a text editor that shows the line numbers
and look at both 308 and 309. Hopefully that will provide
insight. What might be happening is that the script
(workspace) is either referencing a non-existent
column/table, or the script that you cut/pasted uses a
"temporary" name that is no longer present.
...
Darrin"
and
"309 is the line number, use a text editor like ultraedit that shows line numbers.
You can use the function PathToTableName$(Table Full Path) to get the table name that
MapInfo uses
Save yourself a problem and use shorter names.
And the problem here is that it should be just TestAutoBlankBufferTable (without the
.TAB)
Robert Crossley
Agtrix P/L
9 Short St
PO Box 63
New Brighton 2483
Far Southern Queensland
AUSTRALIA
W: www.agtrix.com
W: www.wotzhere.com"
and
"I think, but I could be wrong, that the 309 does indeed refer to the line number
within the workspace, or at least that's how I've always read it! One way round you
problem of having long table names is to use the following statement:
Open Table "C:\GIS stuff\BufferTables\Cairns\TestAutoBlankBufferTable.TAB" As
BlankBuffers Interactive
Open Table "C:\GIS
stuff\BufferTables\Cairns\TrialAutoCasesToBufferForBufferTable1.TAB" As TrialCases
Interactive
then use BufferTable and TrailCases as the table names is subsequent MapBasic
statements. Using short tablenames helps when you have to type in lost of code,
reduces the risk of spelling mistakes (or is that just me)!
The bit of code you think might be erroneous does actually work when I try it out
(with the tablenames changed) so it might well be the long tablenames that is causing
the error.
Greg Driver"
The biggest issue I faced when getting my code to work was that the Buffer( ) command
into the cosmetic layer did not seem to want to work with mulitple objects selected
for buffering. The Create_object_as command did work with multiple objects selected
for buffering however I needed to pre-empt that command with one that opened up a
table that had a .obj column and was available to append the buffer.obj to. In the
above code, i have called that table AutoBufT, but it could be called anything, so
long as the object variable (?? is that what it is called??) was renamed to reflect
the table you had open and available.
I hope this is of some use to someone,
Thanks again for your time,
Alistair Hart
***************************************************
Alistair Hart
Vector Control Officer
Dengue Action Response Team
Tropical Public Health Unit Network
PO Box 1103
Cairns QLD 4870
Ph: 0740 503 628
Fax: 0740 311 440
E: [EMAIL PROTECTED]
"Failure is not an option;
it comes bundled with the software."
***********************************************************************************
This email, including any attachments sent with it, is confidential and for the sole
use of the intended recipient(s). This confidentiality is not waived or lost, if you
receive it and you are not the intended recipient(s), or if it is transmitted/received
in error.
Any unauthorised use, alteration, disclosure, distribution or review of this email is
prohibited. It may be subject to a statutory duty of confidentiality if it relates to
health service matters.
If you are not the intended recipient(s), or if you have received this email in error,
you are asked to immediately notify the sender by telephone or by return email. You
should also delete this email and destroy any hard copies produced.
***********************************************************************************