Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to write a Loop in Batch?

Status
Not open for further replies.

davyzhu

Advanced Member level 1
Advanced Member level 1
Joined
May 23, 2004
Messages
494
Helped
5
Reputation
10
Reaction score
2
Trophy points
1,298
Location
oriental
Activity points
4,436
how to write loop in batch

Hello all,

I want to write a loop in Batch, the idea was written in C.
//------------------------
for(par0=0.1;par0<1;par0=par0+0.1) {
command1 par0 par1;
command2 par0 par2;
command3 par0 par3;
}
//------------------------

//the par is parameter for command

How to change it to Batch(I use NT), thanks!

Regards,
Davy
 

NT's batch mode has no floating point support, but this is better than nothing:

Code:
@echo off
for /L %%X in (1,1,9) do (echo command1 0.%%X par1) & (echo command2 0.%%X par2) & (echo command3 0.%%X par3)
You can remove the "echo" strings later.

From the command prompt, try typing "help for"

I'm using Win2k. Maybe NT is similar.
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Hi

And for unix/linux sh...

Code:
for i in `command generats a sort of listing`
do
//now $i is refer to i-th item in the generated list. do what you want
done
example:

Code:
for i in `ls *.pdf`
do
pdf2txt $i $i.txt
done


tnx
 

    davyzhu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top