Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Read my FAQ:
There's a simpler way to interact with the user, which is using the replaceable parameters. For instance, if the information the user would need to input is "string", the user would invoke the batch file like;
MyBat.bat string
Here's a sample:
@echo off
if not "%1"=="" if not "%1"=="/?" goto start
echo Sintax: %0 parameter
echo.
goto eof
:start
echo You passed %1 as first parameter!
:eofThat batch file will display a help information if no parameter is passed, or if the /? parameter is passed. Otherwise, it will display a message using the passed parameter. Oh, and the %0 represents the batch filename.
However, that method has its limitations, e.g.: a space will break a string into %1 and %2, instead of only %1.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br____________________________________________________________

A simple, but effective way to do what you want to do is to download a DOS version of the SED (UNIX) program and plug it into a DOS script. I found one that works good, Sed_dos(2).exe (I renamed it sed.exe on my local drive), at the following URL: http://www.winnetmag.com/Files/5697/5697.zip
Extract that executable to a directory in your path (I put mine in the root of C:) then try the following script - minus the 'line ends here' comments:
----------
@echo off
cls
echo Let's do some math... [line ends here]
echo Enter a number: [line ends here]
c:\sed -e "s/^/SET INPUT1=/" -e "q" >c:\temp\Input1.bat [line ends here]
CALL c:\temp\Input1.bat [line ends here]
DEL c:\temp\Input1.bat [line ends here]
echo Enter another number: [line ends here]
c:\james\SED\SED -e "s/^/SET INPUT2=/" -e "q" >c:\temp\Input2.bat [line ends here]
CALL c:\temp\Input2.bat [line ends here]
DEL c:\temp\Input2.bat [line ends here]
SET /a Total=%INPUT1% + %INPUT2% [line ends here]
echo Your total is %Total% [line ends here]
IF %INPUT1% LSS %INPUT2% (echo The first number is smaller.) ELSE echo the first number is bigger. [line ends here]
pause
cls
-----
If you want to see all the comparison operators for DOS type the IF help command at the DOS prompt: if /? Hope it helps...

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |