The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Magnum on August 19, 2011, 04:06:58 AM

Title: If question
Post by: Magnum on August 19, 2011, 04:06:58 AM
Sometimes I mess up and delete my resource file before I compile.

Is there a way of using If to make sure rsrc.rc is present before compiling ?

Thanks
Title: Re: If question
Post by: dedndave on August 19, 2011, 04:24:52 AM
i put it in the batch file
this one uses MS Link...
@echo off
if not exist dTest.asm goto AsmEnd
if not exist dTest.inc goto AsmEnd
if not exist dTest.rc goto AsmEnd
if not exist dTest.xml goto AsmEnd
if not exist dTest.ico goto AsmEnd
if exist dTest.res del dTest.res
\masm32\bin\rc /v dTest.rc
if not exist dTest.res goto AsmEnd
if exist rsrc.res del rsrc.res
ren dTest.res rsrc.res
if exist rsrc.obj del rsrc.obj
\masm32\bin\cvtres /machine:ix86 rsrc.res
if not exist rsrc.obj goto AsmEnd
echo.
if exist dTest.obj del dTest.obj
\masm32\bin\ml /c /coff dTest.asm
if errorlevel 1 goto AsmEnd
if not exist dTest.obj goto AsmEnd
echo.
if exist dTest.exe del dTest.exe
\masm32\bin\link /SUBSYSTEM:WINDOWS /OPT:NOREF dTest.obj rsrc.obj

:AsmEnd
if exist rsrc.res del rsrc.res
if exist rsrc.obj del rsrc.obj
if exist dTest.obj del dTest.obj
echo.
dir dTest.*  /o-d
pause


this one uses PoLink...
@echo off
if not exist dTest.asm goto AsmEnd
if not exist dTest.inc goto AsmEnd
if not exist dTest.rc goto AsmEnd
if not exist dTest.xml goto AsmEnd
if not exist dTest.ico goto AsmEnd
if exist dTest.res del dTest.res
\masm32\bin\rc /v dTest.rc
if not exist dTest.res goto AsmEnd
echo.
if exist dTest.obj del dTest.obj
\masm32\bin\ml /c /coff dTest.asm
if errorlevel 1 goto AsmEnd
if not exist dTest.obj goto AsmEnd
echo.
echo PoLink: dTest.asm dTest.res
if exist dTest.exe del dTest.exe
\masm32\bin\polink /SUBSYSTEM:WINDOWS /OPT:NOREF dTest.obj dTest.res

:AsmEnd
if exist dTest.res del dTest.res
if exist dTest.obj del dTest.obj
echo.
dir dTest.* /o-d
pause
Title: Re: If question
Post by: hutch-- on August 19, 2011, 05:08:58 AM
Andy,


@echo off

  if exist rsrc.rc goto proceed
  goto end

:proceed
  @echo It seems to exist.
  goto bye

:end
  @echo Nope, its missing

:bye
  pause
Title: Re: If question
Post by: six_L on August 19, 2011, 08:03:41 AM
use the "eXeScope.exe" to restore .rc from exe.
Title: Re: If question
Post by: jj2007 on August 19, 2011, 08:54:09 AM
Quote from: Magnum on August 19, 2011, 04:06:58 AM
Is there a way of using If to make sure rsrc.rc is present before compiling ?

Here is the version for C programmers, with many many cute brackets :green

@echo off

echo Do you have Masm32?
if exist \masm32\Bin\ml.exe (
echo Yes, it's there!
) else (
echo Nope, can't find it!
)

echo Do you have JWasm?
if exist \masm32\Bin\JWasm.exe (
echo Yes, it's there!
) else (
echo Nope, can't find it!
)

echo Do you have OllyDbg?
if exist \masm32\Bin\OllyDbg.exe (
echo Yes, it's there!
) else (
echo Sorry, it's not in \masm32\Bin
if exist \masm32\OllyDbg\ollydbg.exe (
echo ... but I found it in \masm32\OllyDbg
)
)
pause
Title: Re: If question
Post by: Magnum on August 19, 2011, 01:18:44 PM
I wasn't clear.

I meant something I could put in the code itself.

Ex.

If rsrc.rc isn't present, echo "Your resource file is missing for this project."
Title: Re: If question
Post by: jj2007 on August 19, 2011, 03:48:41 PM
Quote from: Magnum on August 19, 2011, 01:18:44 PM
I wasn't clear.

I meant something I could put in the code itself.

Ex.

If rsrc.rc isn't present, echo "Your resource file is missing for this project."

No problem:

.code
start:
.If !rv(exist, "rsrc.rc")
MsgBox 0, "Your resource file is missing for this project.", "Bad luck:", MB_OK
exit -99
.endif
Title: Re: If question
Post by: Magnum on August 19, 2011, 05:29:51 PM
Thanks.

It's perfect.
Title: Re: If question
Post by: raleeper on August 19, 2011, 07:10:40 PM
Quote from: dedndave on August 19, 2011, 04:24:52 AM
i put it in the batch file
this one uses MS Link...


This looks useful.  Thanks.  I'd like to put some of it in my batch file, if you don't mind. ral
Title: Re: If question
Post by: dedndave on August 19, 2011, 07:11:17 PM
not at all   :P