The 4DOS command processor for MS-DOS

4dos, batch commands, grub 4 dos, dos 4, ms dos 4

do v in 1 2 3

Hello All!

FOR loop allows the following construct:

 for %v in (1 2 3) echo %v

will display

1
2
3

Although DO man pages state that ‘DO v IN set’ is similar to ‘FOR %v IN set’,
 do v in 1 2 3
  echo %v
 enddo

doesn’t work and displays ‘there are no more files: "1 2 3" message which is
bad by itself, but trying to kludge around this feature I’ve discovered even a
more unexpected thing: I’ve tried to run

 do v in 1;2;3
  echo %v
 enddo

And found out that

1. %v is assigned only values of actually existing files or directories, i.e.
if files ’1′ and ’3′ exist, it will display

1
3

Ok, it still may be called a ‘feature’.

2. If the first file (i.e. ’1′) does not exist, it will display an error
message about not being able to locate the first file anyway.

Of course I want DO work exactly as FOR – i.e.

 do v in 1 2 3
  echo %v
 enddo

must display 1 2 3 regardless of what files actually exist.

4OS2 3.01A   OS/2 Version is 3.00
4OS2 Revision A (119)   OS/2 Revision A

:), Leo

— lvm#aha.ru
 * Origin: – The Endless Quest – (2:5020/293)

posted by admin in Uncategorized and have Comments (3)

3 Responses to “do v in 1 2 3”

  1. admin says:

    Leo.V..Miron…@xspam.p0.f293.n5020.z2.fidonet.org wrote:
    > FOR loop allows the following construct:

    >  for %v in (1 2 3) echo %v

    > will display

    > 1
    > 2
    > 3

    > Although DO man pages state that ‘DO v IN set’ is similar to ‘FOR %v IN set’,
    >  do v in 1 2 3
    >   echo %v
    >  enddo

    Try "do v = 1 to 3".

    —————————————————————–
     John English              | mailto:j…@brighton.ac.uk
     Senior Lecturer           | http://www.it.bton.ac.uk/staff/je
     Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
     University of Brighton    |    – see http://burks.bton.ac.uk
    —————————————————————–

  2. admin says:

    It appears to me you need to read the documentation for DO.

    Jerry Runnels
    lsaap…@slinknet.com

    <Leo.V..Miron…@xspam.p0.f293.n5020.z2.fidonet.org> wrote in message

    news:80bbff.6c5303@mach2.v-wave.com…

    - Hide quoted text — Show quoted text -

    > Hello All!

    > FOR loop allows the following construct:

    >  for %v in (1 2 3) echo %v

    > will display

    > 1
    > 2
    > 3

    > Although DO man pages state that ‘DO v IN set’ is similar to ‘FOR %v IN
    set’,
    >  do v in 1 2 3
    >   echo %v
    >  enddo

    > doesn’t work and displays ‘there are no more files: "1 2 3" message which
    is
    > bad by itself, but trying to kludge around this feature I’ve discovered
    even a
    > more unexpected thing: I’ve tried to run

    >  do v in 1;2;3
    >   echo %v
    >  enddo

    > And found out that

    > 1. %v is assigned only values of actually existing files or directories,
    i.e.
    > if files ’1′ and ’3′ exist, it will display

    > 1
    > 3

    > Ok, it still may be called a ‘feature’.

    > 2. If the first file (i.e. ’1′) does not exist, it will display an error
    > message about not being able to locate the first file anyway.

    > Of course I want DO work exactly as FOR – i.e.

    >  do v in 1 2 3
    >   echo %v
    >  enddo

    > must display 1 2 3 regardless of what files actually exist.

    > 4OS2 3.01A   OS/2 Version is 3.00
    > 4OS2 Revision A (119)   OS/2 Revision A

    > :), Leo

    > — lvm#aha.ru
    >  * Origin: – The Endless Quest – (2:5020/293)

  3. admin says:

    *** Answering a msg posted in area .LVM.PERSONAL

    Hello Jerry!

    Mon Nov 13 2000 07:09, Jerry Runnels (1:342/3) wrote to
    Leo.V..Miron…@xspam.p0.f293.n5020:

    JR> It appears to me you need to read the documentation for DO.
    On the contrary, you should read it. This bit in particular:

     The fourth type of loop executes the lines between DO and ENDDO once for
     every member of a set (this is similar to the set used in the FOR command).

    And in my message I’ve shown that in behaves not at all like FOR and does not
    execute lines for each memeber of a set.

    :), Leo

    — lvm#aha.ru
     * Origin: – The Endless Quest – (2:5020/293)