1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DO /P ... is this possible ... ?

Discussion in 'Support' started by vefatica, Aug 15, 2017.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    Is it possible to wrap a command like
    Code:
    do i=1 to 5 ( echo %i )
    in DO /P?
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    Hmm. This doesn't work either:
    Code:
    echo %@execstr[do i=1 to 5 (echos ` `%i)]
     6 6 6 6 6
    
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    I've seen that one before! :-)
    Code:
    v:\> do z in /p (do i=1 to 5 ( echos ` `%i )) (echo %z)
     6 6 6 6 6
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    Hmmm! Putting the /P command in parens does work (in other cases).
    Code:
    v:\ipreg\country> do line in /p (echo foo^r^nbar) (echo %_do_loop %line)
    1 foo
    2 bar
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,971
    Likes Received:
    30
    So I guess the answer tp my original question is "yes". And getting it to work is a matter of doubling up some %s.
    Code:
    v:\ipreg\country> do x in /p ( do i=1 to 3 ( echo %%@eval[%%i**2]) ) ( echo %x foo )
    1 foo
    4 foo
    9 foo
    The same goes for Scott's example.
    Code:
    v:\ipreg\country> echo %@execstr[do i=1 to 5 (echos ` `%%i)]
     1 2 3 4 5
    This is what I wanted to do in the first place. And it works!
    Code:
    v:\ipreg\country> do line in /p (do l in /p grep RU ipcountry.txt (echo %%@eval[0x%%@word[1,%%l]-0x%%@word[0,%%l]+1])) (set /a /q RUSUM+=%line)
    
    v:\ipreg\country> echo %rusum
    45162496
     
  6. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    Ah, the old doubling up of percents trick...
     

Share This Page