Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

nested for loop question

Oct
19
0
These nested for loops

FOR %x IN (@statsdates) (
Echo date= %x
for %y in (m:\taqDAILYTRF\%x) (
echo tickers= %y
)
)

produces this result:

date= 20070601
tickers= m:\taqDAILYTRF\20070601

The first loop works fine -- the second loops fails to list the members of m:\taqDAILYTRF\%x

What am I missing?
 
On 2008-12-22 20:24, rawood11 wrote:

> These nested for loops
>
> FOR %x IN (@statsdates) (
> Echo date= %x
> for %y in (m:\taqDAILYTRF\%x) (
> echo tickers= %y
> )
> )
>
> produces this result:
>
> date= 20070601
> tickers= m:\taqDAILYTRF\20070601
>
> The first loop works fine -- the second loops fails to list the members of m:\taqDAILYTRF\%x

It's hard to answer your question without knowing:
* The contents of the "statsdates" file
* The directory listing of m:\taqDAILYTRF

My first guess would be that the directory you want to see simply
doesn't exist, or you don't have permission to view it.
 
figured out the problem -- /D needed to be removed (show directories only)

On 2008-12-22 20:24, rawood11 wrote:



It's hard to answer your question without knowing:
* The contents of the "statsdates" file
* The directory listing of m:\taqDAILYTRF

My first guess would be that the directory you want to see simply
doesn't exist, or you don't have permission to view it.
 
Seems to me you are missing the @ sign in front of the second filename.

If the desire is to display the contents of the second file (i.e.
m:\taqDAILYTRF\%x) you need to preface it with the @ sign like you did for
your outer loop. If %x references a directory as opposed to a file, you
could use "m:\taqDAILYTRF\%x\*" to get a listing of all the files in that
directory.

FOR %x IN (@statsdates) (
Echo date= %x
for %y in (@m:\taqDAILYTRF\%x) (
echo tickers= %y
)
)

The above loops are almost always better off done with a DO loop due to
the fact that the above multi-line statement is in fact a single
statement. Since you have it written as a multiline statement, I assume
it is part of a batch file. Debugging becmes *much* easier when using
DO/ENDDO.

DO x IN @statsdates
Echo date= %x
DO y in @m:\taqDAILYTRF\%x
echo tickers= %y
ENDDO
ENDDO

-Scott

"JP Software Forums" <[email protected]> wrote on 12/22/2008 02:24:17 PM:


> These nested for loops
>
> FOR %x IN (@statsdates) (
> Echo date= %x
> for %y in (m:\taqDAILYTRF\%x) (
> echo tickers= %y
> )
> )
>
> produces this result:
>
> date= 20070601
> tickers= m:\taqDAILYTRF\20070601
>
> The first loop works fine -- the second loops fails to list the
> members of m:\taqDAILYTRF\%x
>
> What am I missing?
>
>
>
>
 
Back
Top
[FOX] Ultimate Translator
Translate