Solved

Problem with the arithmatic operations like addition.

Posted on 2003-11-19
4
693 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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