X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: return 1; Date: 13 Jan 2002 23:26:27 GMT Organization: Cornell University Lines: 70 Sender: asu1 AT cornell DOT invalid (on pool-141-149-208-172.syr.east.verizon.net) Message-ID: References: <000c01c19c85$ba51f000$2de1a0c8 AT rjo DOT virtua DOT com DOT br> NNTP-Posting-Host: pool-141-149-208-172.syr.east.verizon.net X-Trace: news01.cit.cornell.edu 1010964387 8449 141.149.208.172 (13 Jan 2002 23:26:27 GMT) X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu NNTP-Posting-Date: 13 Jan 2002 23:26:27 GMT User-Agent: Xnews/L5 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Pedro Izecksohn" wrote in news:000c01c19c85$ba51f000$2de1a0c8 AT rjo DOT virtua DOT com DOT br: > Hi, What do happen when main return 1 ? Does the program passes > this value to DOS's ERRORLEVEL ? yes. > Why in my code errorlevel isn't catching > the 1 value ? I'm attaching here the .cc and the .bat codes. did you, by any chance, give the same name to your executable and batch files? if then, dos will execute the exe not the bat file. try the following: === begin: t.bat === @echo off erl if errorlevel 1 goto echo_1 if errorlevel 0 goto echo_0 :echo_1 echo 1 goto end :echo_0 echo 0 :end === end: t.bat === btw, if you use the batch file you posted: > erl > if errorlevel 1 echo 1 > if errorlevel 0 echo 0 you will have both 1 and 0 echoed on the screen because in dos if errorlevel n tests if errorlevel is at least n. so, to make sure errorlevel is equal to 0, you have to do if not errorlevel 1 === begin: modified t.bat to test for errorlevel == 1 === @echo off erl if not errorlevel 1 goto echo_0 if errorlevel 1 goto echo_1 :echo_1 if not errorlevel 2 echo 1 goto end :echo_0 echo 0 :end === end: modified t.bat to test for errorlevel == 1 === hth. Sinan. -- -------------------------------- A. Sinan Unur http://www.unur.com/