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

Author Topic: case statement?  (Read 2878 times)

0 Members and 1 Guest are viewing this topic.

locbtran

    Topic Starter


    Rookie

    case statement?
    « on: May 20, 2009, 08:50:45 PM »
    Is there such a thing as case statement in a batch file?  I check the web and they only use if statement.

    thanks

    BatchFileBasics



      Hopeful

      Thanked: 18
      Re: case statement?
      « Reply #1 on: May 20, 2009, 09:44:35 PM »
      please explain what you mean.
      like case sensitive?

      When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

      gh0std0g74



        Apprentice

        Thanked: 37
        Re: case statement?
        « Reply #2 on: May 20, 2009, 10:44:49 PM »
        Is there such a thing as case statement in a batch file?  I check the web and they only use if statement.

        thanks
        no. 'case' is just a  nicer if/else. Therefore, all you really need is if/else.  if you really really need case support, use *nix shells, eg bash, or other languages that gives you this kind of support.

        Aegis



          Expert

          Thanked: 67
          • Yes
          • Yes
          • Brian's Mess Of A Web Page
        • Experience: Experienced
        • OS: Windows 10
        Re: case statement?
        « Reply #3 on: May 20, 2009, 11:10:36 PM »
        Quote
        case "$var" in
        value1)
        commands;
        ;;
        value2)
        commands;
        ;;
        *)
        commands;
        ;;
        esac

        That's an example like I used to use in my shell scripting days.


        "For you, a thousand times over." - "The Kite Runner"