|
Answer» Hello all,
APOLOGIES in advance if this topic has been done to death but after searching on this site and others for some time I haven't been able to find a solution to my problem. I am running a set of motorised stages via DOS Navigator v1.5 (April 1997) and what I'd like to be able to do is simply run a BATCH file a specified AMOUNT of times.
My batch file (baf.bat) essentially consists of:
call move_fwd %1 call move_bck %2 (move_fwd and move_bck are relative motion batch files written by some long departed person)
this works fine by itself but I need to run it for hundreds or thousands of times so to avoid having to copy and paste that many times I attempted to write a simple loop like (using pseudo-code):
FOR n = %1 baf.bat %2 %3 end
I have tried a number of solutions found here and elsewhere with no success. From what I gather FOR /L doesn't work on this machine, nor does delayedexpansion. Unfortunately I have very little knowledge of DOS code and syntax so I'm floundering in the dark quite a bit here; but this seems like it should have a simple answer...
Thanks in advance for any help.What version of DOS are you using?
It may be possible to call a vbscript to do your calculation
Otherwise, a gwbasic or qbasic program could be used to read a number in a file decrement it store it back in the file if number =0, delete the file
then if you include this in your batch, you would know to stop running when the file did not exist
anyone else with any other ideas?Like gpl, I would think of using Qbasic. if this machine has a full install of a fairly late MS-DOS then Qbasic should be present. You can even create Qbasic programs on the fly in a batch file and then execute them use qbasic /run passing any parameters necessary
Code: [Select]@echo off echo for n = 1 to %1 > myprog.bas echo shell "baf.bat " + "%2" + " " + "%3" >> myprog.bas echo next n >> myprog.bas echo system >> myprog.bas qbasic /run myprog.bas mybatch.bat
Code: [Select]@echo off echo for n = 1 to %1 > testme.bas echo shell "baf.bat " + "%2" + " " + "%3" >> testme.bas echo next n >> testme.bas echo system >> testme.bas qbasic /run testme.bas
baf.bat
Code: [Select]@echo off echo call move_fwd %1 echo call move_bck %2
Hey gpl and Salmon Trout, cheers for the info I shall give that a try once the rig is free again. Yesterday I did just end up copy and pasting 100 times to test it and that works fine. Seems somewhat absurd that there is no way to automate a batch file to run 100 times easily but I guess I'm just too used to fancy-shmancy Matlab. I'll let you know if I get that working, thanks again!Quote from: curriemaster on April 20, 2011, 02:45:37 AM Seems somewhat absurd that there is no way to automate a batch file to run 100 times easily 1. MS-DOS is a operating system from the 1980s and 1990s. It hasn't really changed for 20 years. 2. You can do what you ask for with other tools such as QBasic, which was provided for this sort of thing. 3. You still have not said what OS version you are running.
QuoteWhen current civilization is long gone, anthropologists digging up the rubble find the only thing left intact is... QBASIC (clic here)
Source: Anonymous
|