Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    35

    Where do I post about DOS?

    Dear All,

    Not sure where to post a Dos scripting problem.

    I try to assign a variable with word inside a text file
    On this text file contains word like:
    Line1
    Line2
    Line3
    I want to have my variable with values Line1 Line2 Line3.
    My for loop does not work properly and it seems my variable (test) only store last values (Line3):

    FOR /f %%p in (param.txt) do (
    SET test=%%p %test%
    )

    Any help or a hint to where do I need to post my issue appreciated.
    Thanks.

    cheers

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the closest forum we have would be Applications and Tools

    dbforums.com is a forum site for databases

    you probably want to look for a forum site for operating systems

    try here -- http://google.com/search?q=DOS+forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Your loop/variable is wrong - it's overwriting the variable with the new line each time.
    First time round test = "Line1"
    then it loops and test then = "Line2"
    and once more making test = "Line3"

    There's lots of solutions depending on what you want to do with the variable.
    Example: If you wanted to output it to screen each time
    FOR /f %%p in (param.txt) do (
    SET test=%%p %test%
    <INSERT COMMAND TO WRITE TO SCREEN>
    )

    which would:
    Set variable,
    Write to screen,
    loop back to set variable.
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •