Gah -- forgot about "type" completely.   This would turn the batch file for
TextPad into

@echo off
if %1 == %2 goto link
mapbasic -Nosplash -D %1
goto ckerr
:link
mapbasic -Nosplash -L %1
:ckerr
if exist %3 type %3

We still need to specify the .err file explicitly in order to handle files
with spaces in their names correctly, so the parameters are still

"$FileName" "$BaseName.mbp" "$BaseName.err"

You use the regular expression

^(\([^):]+\): *\([0-9]+\))

to parse output, register 1 for the file name, and register 2 for the line
number.  Works like a charm!

Thanks Peter and Bill.
Spencer

-----Original Message-----
From: Peter Horsbøll Møller [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 27, 2006 2:00 AM
To: Spencer Simpson; mapinfo-l@lists.directionsmag.com
Subject: RE: [MI-L] TextPad as editor for MapBasic

Hi,

I learned this little trick from Bill Thoen some years ago and it has proven
very helpful. 
I also started opening the err file manually, but you don't have the "go to
on doubleclick" when you just open the file. 
I'm not using TextPad but UltraEdit, but I guess the problem is the same.
Using this method the text from the .err file is put into the output window
of UltraEdit.

I have a bat file, that I call from UltraEdit to compile a source file (and
link a project file). At the end the bat file types the err file, if it
exists:

<bat file start>
@Echo Off
"C:\MapBasic\MapBasic 8.0\Mapbasic.Exe" -NOSPLASH -D ""%1.mb"
if exist ""%1.err"" type ""%1.err""
<bat file end>

%1 is the name and path of the source file to compile.

Peter Horsbøll Møller
GIS Developer, MTM
Geographical Information & IT
 
COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark
 
Tel     +45 6311 4900
Direct  +45 6311 4908
Mob     +45 5156 1045
Fax     +45 6311 4949
E-mail  [EMAIL PROTECTED]
http://www.cowi.dk/gis

"For enden af regnbuen..." - hvordan kommer man dertil og er det overhovedet
muligt? 
Læs mere om årets MapInfo konference på www.cowi.dk/mapinfokonference

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Spencer
Simpson
Sent: Wednesday, July 26, 2006 4:13 PM
To: mapinfo-l@lists.directionsmag.com
Subject: RE: [MI-L] TextPad as editor for MapBasic

TextPad has a way of capturing output from a command-line tool, and parsing
it to locate where the compiler said the error occurred.

Unfortunately, MapBasic thwarts this capability, because the compiler always
writes compilation errors to a file with an extension of .err, even when
MapBasic is run from the command line.  If there are no errors, there is no
.err file.  

If the MapBasic compiler had a way to send errors to standard output instead
of the .err file, you could capture the output in TextPad. But it doesn't,
and MapInfo is unlikely to add this functionality.

The best you can do is to open the .err file in TextPad after compilation is
finished.  Unfortunately, there doesn't appear to be a way to make a TextPad
"tool" perform two actions. TextPad's macro functionality appears to be
limited to editing.  So you'll have to make a DOS batch file like the
following:

@echo off
if %1 == %2 goto link
mapbasic -Nosplash -D %1
goto ckerr
:link
mapbasic -Nosplash -L %1
:ckerr
if exist %3 "C:\Program Files\TextPad 4\textpad" %3

Save this in a file named MBTextPad.bat in the same directory as
Mapbasic.exe.   Then add a tool to TextPad (Configure->Preferences... Select
"tools" on the right-hand side, then Add->Program...) that runs
MBTextPad.bat.  The parameters should be 

"$FileName" "$BaseName.mbp" "$BaseName.err"

including all of the  quotes.  Make sure you have "allow multiple instances"
unchecked in Configure->Preferences General or it will open the .err file in
a separate instance.  This method will even work for MapBasic source files
whose names have spaces in them (TextPad is a little too helpful putting
quotes around parameter values with spaces in them).   Perhaps someone is
willing to write a VBScript to make this a bit less clunky.

HTH
Spencer


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard
Greenwood
Sent: Wednesday, July 26, 2006 8:59 AM
To: Manson, Tom, VF UK - Technology (TS)
Cc: mapinfo-l@lists.directionsmag.com
Subject: Re: [MI-L] TextPad as editor for MapBasic

On 7/26/06, Manson, Tom, VF UK - Technology (TS) <[EMAIL PROTECTED]>
wrote:
>
>
>
> Keen MapBasic folk,
>
> We are investigating the use of TextPad as our editor for MapBasic. 
> Does anyone have experience of this? I know that there is an add-on 
> (on
TextPad's
> website) containing all the key words etc, but does someone have a new 
> version of this? Also, how can we get the error messages to  appear, 
> as
they
> would in MapBasic?
>
> Thanks in advance,
>
> Tom

I use Textpad all the time for MapBasic and numerous other languages.
It's an excellent editor. I have not figured out how to get the error
messages back. It has a mechanism for doing it with Java compilers, so it
should be do-able.

-- 

Richard Greenwood
[EMAIL PROTECTED]
www.greenwoodmap.com


_______________________________________________
MapInfo-L mailing list
MapInfo-L@lists.directionsmag.com
http://www.directionsmag.com/mailman/listinfo/mapinfo-l







_______________________________________________
MapInfo-L mailing list
MapInfo-L@lists.directionsmag.com
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to