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

Author Topic: batch file example help  (Read 5473 times)

0 Members and 1 Guest are viewing this topic.

Dias de verano

  • Guest
Re: batch file example help
« Reply #15 on: July 19, 2008, 11:41:15 AM »
This is what is supposed to happen. (Use the code below.)

You run the batch. You see this message:

Code: [Select]
Pick a number (1, 2, or 3)?
So you press 1, 2 or 3. Then you press ENTER (Did you do this?). Then you should see one of these messages depending on what number you chose

Code: [Select]
You have pressed one
Code: [Select]
You have pressed two
Code: [Select]
You have pressed three

Code: [Select]
@echo off
cls
set /p choice= Pick a number (1, 2, or 3)?
IF "%choice%"=="1" goto one
IF "%choice%"=="2" goto two
IF "%choice%"=="3" goto three
goto end
:three
echo You have pressed three
goto end
:two
echo You have pressed two
goto end
:one
echo You have pressed one
:end
pause


carlrowley1

    Topic Starter


    Hopeful

  • liverpool fc
    Re: batch file example help
    « Reply #16 on: July 19, 2008, 12:16:37 PM »
    Quote
    So you press 1, 2 or 3. Then you press ENTER (Did you do this?).


    sorry dias no i did not know you had to press enter NOR did i know about the pause on the end.

    I ve just tryed this out and it works fine...no wonder i was not getting anywhere. .
    I don't know why it did no mention enter and pause in the example,

    I am just getting to know the basic syntax commands and trying a few basic examples "but even that as you know can be a bit confusing"  i need a good manual rather than picking things up from various websites.

    thanks for taking time out to help me
    windowsXP professional sp3, Ram 512 , 1.30 gigahertz AMD Athlon, Maxtor 4r080L0 hard drive.

    Laptop Toshiba.  L300/L300D series/windows vista home premium/
    2gb ram/32 bit/

    Windows 7 / home premium / 64 bit /3gb system ram /

    Dias de verano

    • Guest
    Re: batch file example help
    « Reply #17 on: July 19, 2008, 12:26:53 PM »
    The old CHOICE command did not need you to press Enter after typing your choice, but set /p does need it.

    That page about CHOICE in the Computer Hope commands section is hopelessly wrong.

    I put PAUSE at the end because, without it, if you ran the batch file by double clicking it in Explorer, the screen would close immediately before you could see what happened.

    carlrowley1

      Topic Starter


      Hopeful

    • liverpool fc
      Re: batch file example help
      « Reply #18 on: July 19, 2008, 01:00:48 PM »
      thanks for that dias.

      So i surpose its trail and error OR posting all the time, like getting stuck on that last little problem,  how would i find out about these things before i do something else .

      I only found out substitute-ing the choice command with the set command as that was listed in the example

      So there will be many more surprises in store for me along the way
      windowsXP professional sp3, Ram 512 , 1.30 gigahertz AMD Athlon, Maxtor 4r080L0 hard drive.

      Laptop Toshiba.  L300/L300D series/windows vista home premium/
      2gb ram/32 bit/

      Windows 7 / home premium / 64 bit /3gb system ram /

      Dias de verano

      • Guest
      Re: batch file example help
      « Reply #19 on: July 19, 2008, 01:17:18 PM »
      So there will be many more surprises in store for me along the way

      Yes, and it will be fun, and we will be your guides  :)