Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum operation in batch file

Status
Not open for further replies.

vascobrito

Technical User
Feb 27, 2003
28
PT
Hi there
i need to assign an numeric argument passed to the batch file, wich i have no problem doing. The problem is that i need to assign that value to another variable adding one to the value.i'l explain better.
for instance,the user writes in the prompt:

test.bat 20009

in the batch file i have

SET Guia=%1

in NT/2000 i can simply do what i want with this:

SET /A NewGuia=%Guia% + 1

NewGuia would be = 20010

in dos,95,98 this doesn't work. "SET" doesn't use "/A"

I think i have readed some where that it's not possible to do aritmetic operations in earlier versions of Dos. Is this true, if it is , how can i solve this?

Thanks for any help
 
You are correct. It will not work on earlier versions of DOS.

Solution: pass the number into a program that will add the numbers up (like QBasic or C/C+).

If you don't have any sort of programming language (like the aforementioned) then you could possibly use the one that comes with virtually every DOS & Windows.

Please let us know if you have QBasic or C, first.
--MiggyD
 
Hi MiggyD
I don't have QBasic or C.
Also this is to use in MsDos 5.0 environment.
Thanks
 
I have com up with a solution for my problem but now i have another. I can increase a number of 5 digits, wich is what i want, but now i have to get user input (5 digit number) and that's not a problem. The problem is to separate the digits from the number, wich i need to do to increse the number.
say the user inputs:
test.bat 20056
then i need to separate them 2,0,0,5,6. then i can increase the number to 20057.
thanks
 
sorry, been away on business.

MS-DOS had QBASIC.exe, but you'd have to 'extract' it from the CAB files. Are you sure you can't "extract" it from the CD/Floppies?

Have you tried the MS site? It (may still) provides info on how to extract it and which CAB it's in.

The alternative is to use Debug, which is very nasty if you program it wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top