#: 13639 S0/CompuServe Mail  [MAIL]
     07-Aug-97  14:27:03
 Sb: Comments re: "WAOC++"
 Fm: INTERNET:yojimbo@ix10.ix.netcom.com
 To: Steve Heller [71101,1702]

Hi Steve. I've written before and mentioned that I was working my way
through "Who's Afraid of C++", and I wanted to mention some of my recent
"adventures".

First, I should explain that I'm running the DJGPP software on an
ancient 20 MHz 386 clone (DON'T LAUGH!!)  that I had been using as my
"DOS box" and using very little, at that.  I had installed IBM's PC-DOS
7.0 on this machine as a personal statement against the Microsoft
Hegemony.

In my earlier message to you, I had mentioned that the compilation was
slow. "How slow?" you ask.  Well, the compilation of BASIC01 took 20
minutes when I first did it, and the screen was FLOODED with error
messages that scrolled by for most of that time.  I knew that as a
responsible student, I would have to document those error messages, and
in trying to do so, I have not only eliminated most of them, but I have
gotten the compilation time of BASIC01 down to two minutes, which is
something I can live with.  What did I find?

This may be a "feature" of PC-DOS 7.0, but the new MKNORM.XXX when
renamed .BAT, would produce a "Bad Command or filename" message with
most of the "IF" statements, but not all of them.  I discovered that
separating each line with a blank space solved that problem, and it
seems that separating the :LABELS eliminated many (but not all) of the
"Internal Compiler Error" messages as well, and many of the "multiple
definition" errors I had been getting.  At this time, every line in the
MKNORM.BAT file is followed by a blank line.

In researching the problem, I also learned that DJGPP  will sometimes
throw out an "Internal Compiler Error" message, and according to the
DJGPP newsgroup gurus, this is somehow a problem belonging to the GNU
guys, and not the DJGPP guys, although they didn't provide any details
in the messages I saw.

I also discovered the very useful SCRIPT program, which I'm using now to
automatically capture any error messages to a file.  One of the added
benefits of SCRIPT is that it shows the time it started and the time it
finished, thus approximately documenting the compile time.  I posted a
message on its use in the comp.os.msdos.djgpp newsgroup.

I had been stalled at page 98 for almost a week now while I worked all
this out, and I'm really happy to have solved these problems, and
happier yet that I can now move on in the book.

Thanks, Steve.

-- Jim Hill, Seattle

[later...]

I have continued to think about the problem I had with the batch file,
and I've made even better progress.  It didn't sit quite right with me
that I should have to skip a line after each command in the batch file,
so I consulted a copy of "Supercharging MS-DOS" by Van Wolverton that I
have in my library.  Van was the first computer book author I found who
could write well: I've added "Steve Heller" to that regrettably short
list.  Back to the problem at hand: in the chapter titled "Advanced
Batch File Techniques," Van says, 

"...In particular, watch out for how you test the value of the
parameters.

For example, if a batch file contains  if not %1==fred goto END  and he
batch command is entered with no parameter, DOS displays "syntax error"
and continues with the next command. The error message is distracting,
perhaps even disconcerting. But, depending on what commands follow,
further consequences can be much more serious because, even though the
first parameter isn't "fred," the batch command behaves as if it were.

To avoid this, enclose both the replaceable parameter symbol (% followed
by a number) and the comparison string in quotation marks:  if not
"%1"=="fred" goto END  .  Now DOS handles the absence of the parameter
just like any other parameter value; it doesn't display an error message
and processes the IF command correctly, skipping any commands that
follow the If command and going to the label END.

To check specifically for the absence of a parameter, use two quotation
marks with nothing between as the comparison string: if "$1"=="". "

So I tried this, and it works beautifully. I was able to remove all
those extraneous blank lines from the batch file, and it still runs the
compilation for BASIC01 in two minutes (on my laughable 20 MHz '386
clone) without any of the error messages that were so common before.

I've taken the liberty of attaching the revised batch file below.

-- Jim

----------------- cut here ------------------------------------
gcc -o %1.o -c -I. -g %1.cc -pedantic-errors -Wparentheses
@echo off

if errorlevel 1 goto end

if "%1" == "morbas02" goto end
if "%1" == "itemtst1" goto itemtst1
if "%1" == "itemtst2" goto itemtst2
if "%1" == "itmtst2a" goto itmtst2a
if "%1" == "itemtst3" goto end
if "%1" == "itemtst4" goto itemtst4
if "%1" == "itemtst5" goto itemtst5
if "%1" == "itemtst6" goto itemtst6
if "%1" == "string1" goto end
if "%1" == "string3" goto end
if "%1" == "string4" goto end
if "%1" == "string5" goto end
if "%1" == "string5a" goto end
if "%1" == "string5x" goto end
if "%1" == "string5y" goto end
if "%1" == "string6" goto end
if "%1" == "strex1" goto end
if "%1" == "strex2" goto end
if "%1" == "strex3" goto end
if "%1" == "strex6" goto end
if "%1" == "strtst1" goto strtst1
if "%1" == "strtst3" goto strtst3
if "%1" == "strtst3a" goto end
if "%1" == "strtst4" goto strtst4
if "%1" == "strtst5" goto strtst5
if "%1" == "strtst5a" goto strtst5a
if "%1" == "strtst5x" goto strtst5x
if "%1" == "invent1" goto end
if "%1" == "invent2" goto end
if "%1" == "item1" goto end
if "%1" == "item2" goto end
if "%1" == "item4" goto end
if "%1" == "item5" goto end
if "%1" == "item6" goto end
if "%1" == "wassert" goto end

gxx -o %1 %1.o %djgpprun%/djgpp/lib/stharch.a

goto link

:itemtst1
gcc -o item1.o -c -I. -g item1.cc
gxx -o %1 %1.o item1.o %djgpprun%/djgpp/lib/stharch.a
goto link

:itemtst2
gcc -o item2.o -c -I. -g item2.cc
gxx -o %1 %1.o item2.o %djgpprun%/djgpp/lib/stharch.a
goto link

:itmtst2a
gcc -o item2.o -c -I. -g item2.cc
gxx -o %1 %1.o item2.o %djgpprun%/djgpp/lib/stharch.a
goto link

:itemtst4
gcc -o item4.o -c -I. -g item4.cc
gxx -o %1 %1.o item4.o %djgpprun%/djgpp/lib/stharch.a
goto link

:itemtst5
gcc -o item5.o -c -I. -g item5.cc
gcc -o invent1.o -c -I. -g invent1.cc
gxx -o %1 %1.o item5.o invent1.o %djgpprun%/djgpp/lib/stharch.a
goto link

:itemtst6
gcc -o item6.o -c -I. -g item6.cc

gcc -o invent2.o -c -I. -g invent2.cc
gxx -o %1 %1.o item6.o invent2.o %djgpprun%/djgpp/lib/stharch.a
goto link

:strtst1
gcc -o string1.o -c -I. -g string1.cc
gxx -o %1 %1.o string1.o %djgpprun%/djgpp/lib/stharch.a
goto link

:strtst3
gcc -o string3.o -c -I. -g string3.cc
gxx -o %1 %1.o string3.o %djgpprun%/djgpp/lib/stharch.a
goto link

:strtst4
gcc -o string4.o -c -I. -g string4.cc
gxx -o %1 %1.o string4.o %djgpprun%/djgpp/lib/stharch.a
goto link

:strtst5
gcc -o string5.o -c -I. -g string5.cc
gxx -o %1 %1.o string5.o %djgpprun%/djgpp/lib/stharch.a
goto link

:strtst5a
gcc -o string5a.o -c -I. -g string5a.cc
gxx -o %1 %1.o string5a.o %djgpprun%/djgpp/lib/stharch.a
goto link

:strtst5x
gcc -o string5.o -c -I. -g string5.cc
gxx -o %1 %1.o string5.o %djgpprun%/djgpp/lib/stharch.a
goto link

:link
move %1. ..\normal
move %1.exe ..\normal
del %1.o

:end