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 21200 times)

0 Members and 1 Guest are viewing this topic.

greg



    Intermediate

    Thanked: 7
    Re: Inserting a Blank Space Before Set /P Output
    « Reply #15 on: March 28, 2010, 04:16:03 PM »
    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.

    And you may use Assembly language:

    "A program written in assembly language consists of a series of instructions--mnemonics that correspond to a stream of executable instructions, when translated by an assembler, that can be loaded into memory and executed.:

    reference:  http://en.wikipedia.org/wiki/Assembly_language


    Or

    You may  use machine code.

    Definition: Machine code is the name for the Instructions that a CPU can execute. It's rather difficult to read as it is just numbers in memory. There are programs that can convert the numbers back into assembly language but unless you are pretty skilled or trying to break a protection scheme, there is little use or need for it.
    Compilers generate machine code from your C or C++ source code.

    reference:

    http://cplus.about.com/od/introductiontoprogramming/g/machinecodedefn.htm
    Have a Nice Day

    ghostdog74



      Specialist

      Thanked: 27
      Re: Inserting a Blank Space Before Set /P Output
      « Reply #16 on: March 28, 2010, 06:23:01 PM »
      @grep, i  challenge you use assembly language to solve batch problems next time you post.

      greg



        Intermediate

        Thanked: 7
        Re: Inserting a Blank Space Before Set /P Output
        « Reply #17 on: March 28, 2010, 06:47:26 PM »
        Greg, I  challenge you use assembly language to solve batch problems next time you post.

        I decline the challenge.

        I did not say I used assembly Language. If this were 1970 and I was 30, I would accept the challenge.

        The CH members in charge have suggested we should not import outside
        code for the batch Board. 

        But I enjoy your awk, sed and vbs solutions.

        Keep posting Casper.

         
        Have a Nice Day

        ghostdog74



          Specialist

          Thanked: 27
          Re: Inserting a Blank Space Before Set /P Output
          « Reply #18 on: March 28, 2010, 06:48:40 PM »
          I decline the challenge.
          then why did you post about assembly language? what's the message that you are trying to tell us?

          greg



            Intermediate

            Thanked: 7
            Re: Inserting a Blank Space Before Set /P Output
            « Reply #19 on: March 28, 2010, 07:04:36 PM »
            then why did you post about assembly language? what's the message that you are trying to tell us?

            Maybe  the CH members in charge ( I don't mean CH staff ) are correct about importing too much strange code to a batch board.

            The assembly language post was carrying the idea to an absurd extreme.

            The idea was to make someone laugh.  Humor has no place at CH?

            Have a Nice Day

            gregory

              Topic Starter


              Beginner

              Thanked: 1
              • Experience: Experienced
              • OS: Linux variant
              Re: Inserting a Blank Space Before Set /P Output
              « Reply #20 on: March 29, 2010, 05:06:43 AM »
              How odd this has become.

              Geek-9pm


                Mastermind
              • Geek After Dark
              • Thanked: 1026
                • Gekk9pm bnlog
              • Certifications: List
              • Computer: Specs
              • Experience: Expert
              • OS: Windows 10
              Re: Inserting a Blank Space Before Set /P Output
              « Reply #21 on: March 29, 2010, 01:00:14 PM »
              This part of the forum is about using either DOS or love command prompt in windows XP, Vista  or comparable Windows operating system.
              Apparently the original poster wants to show a prompt with a space in front of it and then the user must enter a value and hit return. This will set the value to a variable that can be used to later in a batch file. At least that is what I understand.

              Perhaps it would help if the original poster could give some explanation as to why a space is needed before the prompt. For some reason I have an uncomfortable feeling that this is some kind of effort to camouflage an attack on an existing application. Otherwise, the original poster could just modify some other part of this program to make sure the space is there before the prompt. However, I have been criticized for making accusations like this. So I would like to respectfully ask the original poster. Why do you need to have a space before the prompt?

              And yes, it would be quite easy to come up with an assembly language or machine language solution to this problem that would require a very small amount of code. However, use of machine level code is considered to be a potential threat and is not favored by other members of this form.

              Salmon Trout

              • Guest
              Re: Inserting a Blank Space Before Set /P Output
              « Reply #22 on: March 29, 2010, 03:19:47 PM »
              Perhaps it would help if the original poster could give some explanation as to why a space is needed before the prompt. For some reason I have an uncomfortable feeling that this is some kind of effort to camouflage an attack on an existing application.

              I have wanted to do this in order to have a margin at the left side of the command window, because it looks better than starting right at the edge of the window. I used VBScript.

              gregory

                Topic Starter


                Beginner

                Thanked: 1
                • Experience: Experienced
                • OS: Linux variant
                Re: Inserting a Blank Space Before Set /P Output
                « Reply #23 on: March 29, 2010, 10:05:29 PM »
                Otherwise, the original poster could just modify some other part of this program to make sure the space is there before the prompt.

                A space before where the user will input is not a problem. However a space before the promptString is apparently impossible in Vista on up.

                So I would like to respectfully ask the original poster. Why do you need to have a space before the prompt?
                I have wanted to do this in order to have a margin at the left side of the command window, because it looks better than starting right at the edge of the window.

                Bingo. All of my screen output has a margin of 1 space from the left edge. All that is, except for the set /p's. >:(
                Nothing evil is afoot, I promise, really, nothing like that at all, for sure, cross my heart, no really, nothing like that.

                Geek-9pm


                  Mastermind
                • Geek After Dark
                • Thanked: 1026
                  • Gekk9pm bnlog
                • Certifications: List
                • Computer: Specs
                • Experience: Expert
                • OS: Windows 10
                Re: Inserting a Blank Space Before Set /P Output
                « Reply #24 on: March 29, 2010, 11:39:33 PM »
                Perhaps the most piratical solution is to go with PowerShell.
                http://support.microsoft.com/kb/926139/en-us
                The above link is for XP.

                Salmon Trout

                • Guest
                Re: Inserting a Blank Space Before Set /P Output
                « Reply #25 on: March 30, 2010, 04:43:33 AM »
                If you can download and use third party executables there is Bill Stewart's free Editvar utility. The zip contains executables and also good help text files with full usage details. One very useful feature in optional input masking.

                http://www.westmesatech.com/editv.html

                There are quite a few other handy utilities at this site.

                put the executable editv32.exe or editv64.exe either in the batch folder or somewhere on your PATH or put it in a folder of your choosing and use its full path in your batch e.g. "C:\My Scripts\editv32.exe" -p " Type something" Variable

                example batch file

                Code: [Select]
                @echo off
                echo (1) using set /p
                set Myname=
                echo.
                set /p "Myname= Enter your user name: "
                echo %Myname%
                echo.
                echo (2) using editvXX
                set Myname=
                echo.
                editv32 -p " Enter your user name: " Myname
                echo  %Myname%
                echo.
                echo (3) Hide input text
                set Myname=
                echo.
                editv32 -m -p " Enter your user name: " Myname
                echo  %Myname%

                output
                Code: [Select]
                (1) using set /p

                Enter your user name: Jim
                Jim

                (2) using editvXX

                 Enter your user name: Bob
                 Bob

                (3) Hide input text

                 Enter your user name: ****
                 Bill





                « Last Edit: March 30, 2010, 05:00:35 AM by Salmon Trout »

                ghostdog74



                  Specialist

                  Thanked: 27
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #26 on: March 30, 2010, 05:00:07 AM »
                  If you can download and use third party executables there is Bill Stewart's free Editvar utility. The zip contains executables and also good help text files with full usage details. One very useful feature in optional input masking.
                  good to know. But i will stick to Python/Perl  for a well rounded scripting solution. :)

                  Salmon Trout

                  • Guest
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #27 on: March 30, 2010, 05:04:43 AM »
                  good to know. But i will stick to Python/Perl  for a well rounded scripting solution. :)

                  "well rounded..." subjective view... language partisans... harrumph...

                  My remarks were mainly addressed to the OP who requested (it seems to me) a batch solution, which has not so far been forthcoming, not that I wish to revive the old "answer the question as posed vs. suggest they try another language/OS/whatever" debate. Although I agree that suggesting other approaches can be a very helpful and positive step, sometimes an OP just wants a quick (and possibly in the eyes of some people, dirty) solution, rather than a Comp Sci lesson.


                  BC_Programmer


                    Mastermind
                  • Typing is no substitute for thinking.
                  • Thanked: 1140
                    • Yes
                    • Yes
                    • BC-Programming.com
                  • Certifications: List
                  • Computer: Specs
                  • Experience: Beginner
                  • OS: Windows 11
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #28 on: March 30, 2010, 07:18:06 AM »
                  sometimes an OP just wants a quick (and possibly in the eyes of some people, dirty) solution, rather than a Comp Sci lesson.

                  Exactly.

                  In fact I'm surprised there aren't code architects here that try to post some full-featured Object-hierarchy for every single problem.

                  "And then you simply need to derive a new class from this particular CTextWithaSpaceInFrontOfIt base class, and then return the text to output in the overridden WriteText() Method. Also don't forget to set the ReturnFormatter property to an instance of an object that implements the IReturnFormatter interface. You can use the CReturnFormatter class for this if necessary, it performs default handing of IReturnFormatter by not formatting anything at all."

                  A lot of people, when they take their car into the shop, they really don't care that their Alternator Selenoid needs topping up or that there is a leak in their carburetor or what is causing their problems. That's why they went to the shop, to fix whatever is wrong.

                  Not everybody can be an expert in everything; many Posters here have no intention of getting into programming and are merely trying to do their job; while, as Salmon Trout says, it does no harm to suggest other alternatives like Python/Perl, When you reference it time and time again in repeated posts afterward even after the OP has expressed disinterest in the solution just makes you look like a hard-headed evangelist. Python and Perl are programming languages. They are no worse nor no better overall then any other. No Programming language has <everything> you could ever need. Sure Python/Perl have modules you can use for nearly everything; so does VBScript. It's called COM. and COM components are a lot easier to use from VBScript as compared to either Python or Perl (which in themselves need a module for this purpose), why? because VBScript was designed solely as a glue language, and specifically as a consumer of these COM components. Python/Perl were not designed with the ability to use COM components; they still can, if you know the proper Voodoo. (and god forbid you have to deal with COM errors in either one)

                  I was trying to dereference Null Pointers before it was cool.

                  Salmon Trout

                  • Guest
                  Re: Inserting a Blank Space Before Set /P Output
                  « Reply #29 on: March 30, 2010, 07:23:30 AM »
                  When you reference it time and time again in repeated posts afterward even after the OP has expressed disinterest in the solution just makes you look like a hard-headed evangelist.

                  Or a show-off, somebody who likes to feel like a big fish so seeks out small ponds to splash around in. Not that I have anybody in particular in mind.