Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with the arithmatic operations like addition.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

791 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