Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!dptg!pegasus!hansen From: hansen@pegasus.ATT.COM (Tony L. Hansen) Newsgroups: comp.lang.c++ Subject: Re: C++ for DOS/OS2 Summary: handling errorlevels Keywords: C++, Glockenspiel, DOS Message-ID: <4116@pegasus.ATT.COM> Date: 26 Sep 89 15:29:22 GMT References: <661@windy.dsir.govt.nz> <1456@dinl.mmc.UUCP> <672@windy.dsir.govt.nz> <4109@pegasus.ATT.COM> <11895@cgl.ucsf.EDU> Reply-To: hansen@pegasus.ATT.COM (Tony L. Hansen) Organization: AT&T Bell Labs Middletown/Lincroft NJ USA Lines: 72 << When I use one of the cfront ports under DOS, I found this small trick << useful. Because cfront can run out of memory so easily, even using make << can push things over the limit. So instead of running make directly to << build things, I run it indirectly via a small batch file: <tmp.bat << tmp < The disadvantage of this technique is that "mk.bat" won't stop if a < compiler error happens. Quite true. I'd forgotten that I handled that as well. (I didn't have my DOS machine handy at the time I wrote the previous message. Sigh. I really dislike using extra bandwidth.) The real mk.bat file has one additional line in it: mk.bat: make -n %1 %2 %3 %4 %5 %6 %7 %8 %9 > tmp.bat ed - tmp.bat < c:\xbin\tmpmak.ed tmp ed is the old standby; I use MKS's version. The script tmpmak.ed is simple; it adds "if" tests after each line plus an ":error" label at the end: tmpmak.ed: H g/^/a\ if errorlevel 1 goto error . $a :error . w q I'm certain that similar things can be done with other line editors, such as edlin. A simple C program could also be used. adderror.c: #include main() { char buf[1024]; while (fgets(buf, sizeof buf, stdin)) { fputs(buf, stdout); fputs("if errorlevel 1 goto error\n", stdout); } fputs(":error\n", stdout); return 0; } and mk.bat becomes mkbat: make -n %1 %2 %3 %4 %5 %6 %7 %8 %9 > tmp.bat adderror < tmp.bat > tmp2.bat tmp2 < At the risk of sounding like a plug, my OPUS MAKE program swaps itself < from memory before spawning its shell lines, reducing its memory < requirements to about 3K. I can supply more information to anyone who is < interested. Unfortunately, I've had occasions where even 3K made a difference. The mk.bat scheme requires NO memory overhead besides DOS and command.com. (Other than that, your make program sounds great.) Tony Hansen att!pegasus!hansen, attmail!tony hansen@pegasus.att.com