Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file write variables to file  (Read 29873 times)

0 Members and 1 Guest are viewing this topic.

marvinengland



    Hopeful

    Thanked: 11
    Re: Batch file write variables to file
    « Reply #15 on: June 11, 2010, 01:16:23 PM »
    The problem is that it does not write the variables to the file. It only partially works when I remove the whole if statement. . I thought this was because I have a space before the >>, but when I remove the space it doesn't work at all. So can someone that understands this convoluted language help me figure this out?

    There is no problem. A trailing space for a redirect ( >> )
    does not cause a problem.  There is no need to remove
    the trailing space. This  complete thread is nonsense.


    USA

    Salmon Trout

    • Guest
    Re: Batch file write variables to file
    « Reply #16 on: June 11, 2010, 01:21:47 PM »
    This complete thread is nonsense.

    The parts that you contributed are. Why don't you leave? Please.

    Linux711

      Topic Starter


      Mentor

      Thanked: 59
      • Yes
      • Programming Blog
    • Certifications: List
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Batch file write variables to file
    « Reply #17 on: June 11, 2010, 05:47:14 PM »
    Quote
    There is no problem. A trailing space for a redirect ( >> )
    does not cause a problem.  There is no need to remove
    the trailing space.

    Don't you realize that there might be something other than human eyes reading this file.



    @BC_Programmer

    Thank you. The escape ^ works. I adjusted the code a little. Removed the !in! !in2! !in3! and just made everything !in! because there is no point in using a new variable each time. I also fixed the file name issue.

    Here is the final code. It works perfectly. No need for any more arguments.

    Code: [Select]
    @echo off
    setlocal enabledelayedexpansion
    set /p yorn=Would you like to setup the server name etc.(y/n)?
    if /i %yorn%==y (
            set /p in=Maximum clients:
            echo maxclients !in!> bla.cfg
            set /p in=Bot limit:
            echo serverbotlimit !in!>> bla.cfg
            echo publicserver ^0>>bla.cfg
            set /p in=Server title:
            echo serverdesc "!in!">> bla.cfg
    ) else (
            echo said no.
    )

    PS: Does anyone know how to mark resolved on this forum?
    YouTube

    "Genius is persistence, not brain power." - Me

    "Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: Batch file write variables to file
    « Reply #18 on: June 11, 2010, 06:36:02 PM »
    A trailing space for a redirect ( >> )
    does not cause a problem.  There is no need to remove
    the trailing space.
    @echo off
    echo Comparing requires no trailing spaces > file.txt
    set /p var=<file.txt
    if not "Comparing requires no trailing spaces"=="%var%" echo FAIL!
    pause

    It is also affects FTP scripts, too. Just so you know.
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.