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

Author Topic: Inserting a Blank Space Before Set /P Output  (Read 22633 times)

0 Members and 1 Guest are viewing this topic.

gregory

    Topic Starter


    Beginner

    Thanked: 1
    • Experience: Experienced
    • OS: Linux variant
    Inserting a Blank Space Before Set /P Output
    « on: March 27, 2010, 04:25:52 AM »
    How does one get a blank space to appear before the output of a set /p command?

    For example:

    Code: [Select]
    set /p var=helloThis will display hello on the line. I need a blank space to come before that.

    Thanks all.

    vilsol



      Greenhorn

      Re: Inserting a Blank Space Before Set /P Output
      « Reply #1 on: March 27, 2010, 04:54:17 AM »
      echo.

      gregory

        Topic Starter


        Beginner

        Thanked: 1
        • Experience: Experienced
        • OS: Linux variant
        Re: Inserting a Blank Space Before Set /P Output
        « Reply #2 on: March 27, 2010, 05:09:55 AM »
        Echo will display everything on the line, including "set /p var=".

        vilsol



          Greenhorn

          Re: Inserting a Blank Space Before Set /P Output
          « Reply #3 on: March 27, 2010, 05:12:14 AM »
          i said something like this
          Code: [Select]
          echo.
          set /p var=hello

          gregory

            Topic Starter


            Beginner

            Thanked: 1
            • Experience: Experienced
            • OS: Linux variant
            Re: Inserting a Blank Space Before Set /P Output
            « Reply #4 on: March 27, 2010, 05:14:58 AM »
            i said something like this
            Code: [Select]
            echo.
            set /p var=hello

            That would insert a blank line.

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: Inserting a Blank Space Before Set /P Output
            « Reply #5 on: March 27, 2010, 05:36:36 AM »
            The set command takes everything literally. If you want a leading space before the 'hello', insert one:

            Code: [Select]
            set /p var= Hello

            This is also true of trailing characters.

             8)
            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            gregory

              Topic Starter


              Beginner

              Thanked: 1
              • Experience: Experienced
              • OS: Linux variant
              Re: Inserting a Blank Space Before Set /P Output
              « Reply #6 on: March 27, 2010, 05:38:56 AM »
              The set command takes everything literally. If you want a leading space before the 'hello', insert one:

              Code: [Select]
              set /p var= Hello

              This is also true of trailing characters.

               8)

              Funny, that doesn't work for me.

              Sidewinder



                Guru

                Thanked: 139
              • Experience: Familiar
              • OS: Windows 10
              Re: Inserting a Blank Space Before Set /P Output
              « Reply #7 on: March 27, 2010, 05:52:31 AM »
              Funny, that doesn't work for me.

              OK. Let's start at the beginning. What OS are you using? The command posted should work on NT machines either at the command line or in a batch file.

               8)
              The true sign of intelligence is not knowledge but imagination.

              -- Albert Einstein

              gregory

                Topic Starter


                Beginner

                Thanked: 1
                • Experience: Experienced
                • OS: Linux variant
                Re: Inserting a Blank Space Before Set /P Output
                « Reply #8 on: March 27, 2010, 06:02:30 AM »
                The current machine is running Vista.

                You're telling me that if you run the following code in a .cmd file it shows a space before "hello"?
                Code: [Select]
                @ echo off

                set /p var= hello

                *Edit

                Perhaps I've caused some confusion. I'm wanting a space literally displayed on the screen output.

                Sidewinder



                  Guru

                  Thanked: 139
                • Experience: Familiar
                • OS: Windows 10
                Re: Inserting a Blank Space Before Set /P Output
                « Reply #9 on: March 27, 2010, 06:27:20 AM »
                The current machine is running Vista.

                You're telling me that if you run the following code in a .cmd file it shows a space before "hello"?

                It does on XP. Note there should not be a space between the @ and echo on the first line, however it still works!

                Are you sure you're in Command prompt and not MS-DOS Prompt?

                 8)
                The true sign of intelligence is not knowledge but imagination.

                -- Albert Einstein

                gregory

                  Topic Starter


                  Beginner

                  Thanked: 1
                  • Experience: Experienced
                  • OS: Linux variant
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #10 on: March 27, 2010, 06:38:34 AM »
                  Are you sure you're in Command prompt and not MS-DOS Prompt?

                  Yup, it's a .cmd file that executes in cmd.exe.

                  And it's certainly not working for me in Vista. Perhaps someone on Vista or 7 would be nice enough to test it out.
                  Any other thoughts? I really do appreciate the effort.

                  Sidewinder



                    Guru

                    Thanked: 139
                  • Experience: Familiar
                  • OS: Windows 10
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #11 on: March 27, 2010, 06:46:03 AM »
                  You're right, perhaps someone with Vista will see the problem. Interesting note, a cmd file with your code runs in both the MS-DOS Prompt and the Command Prompt. At the console however it only works in Command Prompt.

                  Good luck. 8)

                  You could try closing the command window and reopening it. Sometimes just a reset will work wonders.
                  The true sign of intelligence is not knowledge but imagination.

                  -- Albert Einstein

                  Salmon Trout

                  • Guest
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #12 on: March 27, 2010, 07:51:42 AM »
                  XP Professional SP3 32 bit

                  Code: [Select]
                  Microsoft Windows XP [Version 5.1.2600]
                  (C) Copyright 1985-2001 Microsoft Corp.

                  C:\>set /p var= hello
                   hello

                  Windows 7 Professional 64 bit

                  Code: [Select]
                  Microsoft Windows [Version 6.1.7600]
                  Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

                  C:\>set /p var= hello
                  hello

                  gregory

                    Topic Starter


                    Beginner

                    Thanked: 1
                    • Experience: Experienced
                    • OS: Linux variant
                    Re: Inserting a Blank Space Before Set /P Output
                    « Reply #13 on: March 27, 2010, 08:10:20 AM »
                    Thanks for confirming that.
                    Any idea what else could be done? :)

                    ghostdog74



                      Specialist

                      Thanked: 27
                      Re: Inserting a Blank Space Before Set /P Output
                      « Reply #14 on: March 27, 2010, 05:59:13 PM »
                      Any idea what else could be done? :)
                      sure, you can learn to use vbscript or powershell. Or get a real programming language like Perl or Python for your batch scripting needs.. they are way better than what cmd.exe can offer.