Computer Hope
Microsoft => Microsoft DOS => Topic started by: Woofy613 on September 14, 2008, 09:17:12 PM
-
I wish to do the following, which I am writing in pseudo code.
What I wish to be able to do is to run a program, reading from sequential data files [name%1]. I wish to increment the calculation until the last data file [name%3] is reached. I also will be calling other batch flies to rename or copy the original output.
The range of %1 can be from 1 to 200 [or larger]
I am a newbie, so please excuse me...
The command line is:
batchfile %1 %2 %3
The batch file is:
:start
if %1 is greater than %3 goto end
program1 %1 %2
call prog1 %1 %2
call prog2 %1 %2
increment %1 by one
go to start
:end
exit
-
set var=%1
:LOOP
if '%1' gtr '%3' goto :EOF
program1 %var% %2
call prog1 %var% %2
call prog2 %var% %2
set /a var+=1
goto LOOP
-
Thanks.
Some problems:
1] I get a syntax error in this line: if '%1' gtr '%3' goto :EOF
2] var never increments
Advice please.
Thanks again.
-
@echo off
set /a var=%1
:LOOP
if %var% gtr %3 goto :END
program1 %var% %2
call prog1 %var% %2
call prog2 %var% %2
set /a var+=1
goto LOOP
:END
-
Thanks.
I have the same problems, even with the edits suggested.
1] No matter how I try to edit this line, I get syntax errors
if %var% gtr %3 goto :END
2] var never increments
Thanks again.
-
are you know how to use %1 %2 and %3 ??
-
are you know how to use %1 %2 and %3 ??
That is what I am wondering. There is a strong smell of homework around this thread.
-
are you know how to use %1 %2 and %3 ??
That is what I am wondering. There is a strong smell of homework around this thread.
dun dun dun.
;)
-
OS Win2000 SP4
The file is test.bat
command line: test 1 3
file:
echo on
set /a var=%1
:LOOP
IF %var% GTR %2 GOTO :end
echo that's it
set /a var+=1
goto loop
:end
echo end it
exit
error message
IF GTR 3 GOTO :end
syntax error.
Where have I made my mistake??
-
One correction:
My OS is DOS 7.1, the last pure DOS from Microsoft. It is the one that comes with Windows 98. My machine runs ONLY this DOS. There is no Windows on the box.
-
You don't get set /a with genuine MS-DOS. Only NT4 and later members of NT family. That's why you're getting the error.
-
Thank you.
Is there anything I can do to make it work, possibly different code in the batch file?
-
Time to start learning QBasic.
-
Thank you for all your excellent help.
I would not like to be forced to learn another language now. I have 100 massive data files to analyze and I would like to be able to loop thru them w/o having to baby sit the computer.
Is there any work around? I would assume that people programming in pure DOS have had this problem and found a solution.
Thanks again.
-
In general, people have moved on from "programming in pure DOS" as you call it. When it was the only game in town, many people did learn QBasic, for precisely the reasons you are finding.
-
Dias -
Thank you. I appreciate your comment. However ....
Eventually my programs will be ported to UNIX and I need to be able to develop them in DOS so that I can port. Qbasic is a Microsoft Language, that does not exist in UNIX.
If I could rely on your expertise, to "think outside of the box", it would be appreciated. In other words, lets see if we can think in an innovative way to solve this.
Does anybody else on this forum have any ideas??
Thanks again.
-
if this is going to be proted to unix, why not transfer the files into unix environment and make use of unix utilities like integer arithmetic at the ksh prompt. What you are trying to do seems to be impossible in the pure dos environment unless you can find a dos command line calculator to give you increments.
qbasic, along with being from microsoft, is pretty benign language and very easy to comprehend. I believe there are even some free basic interpreters which can use the qbasic code with little to no modification. so learning it would not be so bad of an idea. If you have the basic understanding of programming languages, you are more than half way thru anyways.
good luck