A MapInfo 3.0 and MapBasic 3.02 on Windows XP (still works!) question or
two.
I have a project that required that I detect which polygons overlap which
other polygons in a single table. I know how to do this with the technique
of duplicating the table and selecting those polygons from one table that
intersect others in the second table when the polygon's id's are different.
This works well and produces the results I need.
I'd like to modify the code so that I can use it with any tables and so that
I can run it from a Startup.wor workspace without any user intervention.
------------------------ code follows --------------------------
include "mapbasic.def"
declare sub main
sub main
Select *
from MapCpy1, MapCpy2
where (MapCpy1.Obj Intersects MapCpy2.Obj)
and (MapCpy1.DATA1 <> MapCpy2.DATA1)
order by MapCpy1.TERRITORY, MapCpy2.TERRITORY
into Overlaps
open file "overlaps.out" for output as #1
fetch first from overlaps
do while not eot( overlaps )
write #1, Overlaps.Col(2), Overlaps.Col(6)
fetch next from overlaps
loop
close file #1
end sub
------------------------ code precedes --------------------------
This code requires that I call the two tables MapCpy1 and MapCpy2. It would
be better if I could pass in the names of the tables to the mapbasic code
both from a command line and thence into variables that are then used in the
selection.
What modifications should I make to this code to achieve these ends?
The MapBasic manual is somewhat vague about obtaining parameters from a
mapbasic application's command line. How can I access parameters from
within the mapbasic code?
I can startup and get MapInfo to run an .mbx by writing a Startup.wor file
that resembles this example from the MapInfo help file:
!workspace
!version 200
run application "someprog.mbx"
Where someprog.app is the name of the MapBasic application you want
to launch from the startup workspace. Name this file STARTUP.WOR. Place
this file in your MapInfo program directory or in your home directory.
This information is also in the MapInfo help file as examples of starting up
either compiled MapBasic code or starting up other workspaces:
Run Application "C:\MAPBASIC\APP\REPORT.MBX"
Run Application "Parcels.wor"
Then, the MapInfo help file says that MapInfo launches and performs the
following steps:
When you run MapInfo, MapInfo does the following in the order
shown:
1. If there is a STARTUP.WOR in the MapInfo program directory, it
is run.
2. Then, if there is a STARTUP.WOR in your home directory it is
run. (When there is a STARTUP.WOR in both the MapInfo program directory
and your home directory, both are run.)
3. Then, if any file names are given on the command line or MapInfo
was launched by double-clicking a document in the Macintosh Finder those
file(s) are loaded. MapInfo support adding workspaces (.WOR), running
applications (.APP), and opening databases (.TAB) on the command line.
4. Only if MapInfo did not add a workspace or run a program from
the command line does it then check the AutoLoad preference and load
MAPINFOW.WOR from the user's home directory. When the preference is set,
and the file is found, it is loaded. Note that if we had a workspace or
application on the command line, we skip the AutoLoad.
5. Finally, if MapInfo didn't load a workspace or run an
application from the command line, and it didn't AutoLoad MAPINFOW.WOR, then
MapInfo shows the Tool palette.
I'd guess that the writer of this help file was last working on a Mac and
left the .APP extension rather than changing it to .MBX.
None of this seems to support the passing of parameters to a .MBX on the
command line. Is it really so that user interaction is required to obtain
the names of the .TAB files that could be supplied on a command line?
As one final question, can MapBasic 3.0 be used as a command line compiler
or are you forced to use it like Turbo Pascal 3.0 where you had to use the
built-in IDE?
Sorry for novice questions and the lengthy email.
Stu Cox
Project Management Technician
Southern Interior Region
Ministry of Transportation
523 Columbia St.,
Kamloops, BC V2C 2T9
p: 250-828-4320
f: 250-828-4492
[EMAIL PROTECTED]
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12868