Solved

Problem with the arithmatic operations like addition.

Posted on 2003-11-19
4
671 Views
Last Modified: 2008-02-01
Hi,
I am trying to write a batch file which takes two parameters are input. The prog is given below.

for %j IN (1,1,%1) do GOTO=LOOP
:LOOP
IF %j == %1 GOTO END
set PRNNO = %2 + %j
echo %PRNNO%

:END

here the for loop has to go on till %1 number of times with increments of 1. Then each time it has to display the sum of the j value in the loop and the second parameter. Can some body help me in this regard.

-Kiran
0
Comment
Question by:bkirankumar
4 Comments
 
LVL 5

Accepted Solution

by:
brianadkins earned 125 total points
ID: 9782794

Here's a first guess:

---------------8<------------------
set INPUT1=%1
set INPUT2=%2

for /l %%a in (1,1,%INPUT1%) do call :LOOP %%a

goto :END
:LOOP
set /a PRNNO=%INPUT2%+%1
echo %PRNNO%

:END
---------------8<------------------

-Brian
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now