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

Author Topic: if exit..  (Read 24218 times)

0 Members and 1 Guest are viewing this topic.

11victory11

    Topic Starter


    Rookie

    if exit..
    « on: March 19, 2008, 09:30:08 PM »
    how do i make it so that if the ms-dos is exit that it will then start a file or a code?
    and for this code here i would like it for when it goes to equ 1 and equ 3 how do i make it so that they goto a differnt secton

    set /a var=%random%%%4



    if %var% equ 0 set one=I like it cause of that to.
    if %var% equ 1 set one=eww, are you sure?
    if %var% equ 2 set one=Wow, never thought of that.
    if %var% equ 3 set one=Are you sure?
    echo %one%
    « Last Edit: March 20, 2008, 04:50:49 PM by 11victory11 »

    Dias de verano

    • Guest
    Re: if exit..
    « Reply #1 on: March 20, 2008, 07:36:01 AM »
    the word 'sure' is spelt thus.

    macdad-



      Expert

      Thanked: 40
      Re: if exit..
      « Reply #2 on: March 20, 2008, 09:27:20 AM »
      well if u want the code to exit to start another bat file then make another batch file, and then type the code like this on the first batch file
      Code: [Select]
      start <name of batch prog>
      exit
      and then for the batch code above if u want it to goto different sections try this
      Code: [Select]
      set /a var=%random%%%4



      if %var% equ 0 set one=I like it cause of that to.
      if %var% equ 1 set one=eww, are you shurr?
      if %var% equ 2 set one=Wow, never thought of that.
      if %var% equ 3 set one=Are you shurr?
      echo %one%
      pause
      goto %one%

      then for the different sections make sure u type a colon before the label but there cant be any spaces in the label or else DOS will close the program. so try this to mark each section(this label will mark the "I like it cause of that to" section- :Ilike)
      try the ":Ilike" label for that particular section make sure it has a colon and that there arent any spaces.
      If you dont know DOS, you dont know Windows...

      Thats why Bill Gates created the Windows NT Family.

      Dias de verano

      • Guest
      Re: if exit..
      « Reply #3 on: March 20, 2008, 10:50:53 AM »

      Code: [Select]
      goto %one%

      You can't do this. (Expand a variable to a label name & goto it)




      macdad-



        Expert

        Thanked: 40
        Re: if exit..
        « Reply #4 on: March 20, 2008, 11:59:59 AM »
        ok...now try this
        Code: [Select]
        set /a var=%random%%%4



        if %var% equ 0 set one=I like it cause of that to.
        if %var% equ 1 set one=eww, are you shurr?
        if %var% equ 2 set one=Wow, never thought of that.
        if %var% equ 3 set one=Are you shurr?
        echo %one%
        pause
        label %one%
        goto one
        If you dont know DOS, you dont know Windows...

        Thats why Bill Gates created the Windows NT Family.

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: if exit..
        « Reply #5 on: March 20, 2008, 12:49:11 PM »
        From testing, I discovered you can in fact expand a label name go to it:

        Code: [Select]
        set  one=two
        if errorlevel 0 goto %one%
        goto :eof

        :two
        echo %one%

        If you leave echo on you can see the expansion in real time. You cannot however expand a variable as part of a label:

        Code: [Select]
        set  one=two
        if errorlevel 0 goto %one%
        goto :eof

        :%one%
        echo %one%

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

        -- Albert Einstein

        Dias de verano

        • Guest
        Re: if exit..
        « Reply #6 on: March 20, 2008, 01:11:46 PM »
        label %one%

        What does this line do?

        PS Can we spell "sure" properly please?



        Dias de verano

        • Guest
        Re: if exit..
        « Reply #7 on: March 20, 2008, 01:14:47 PM »
        From testing, I discovered you can in fact expand a label name go to it:

        So you can, I now see. I was always taught that self-modifying code is a bad idea, however.

        Quote
        You cannot however expand a variable as part of a label:

        I think that was what I was thinking of.

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: if exit..
        « Reply #8 on: March 20, 2008, 01:25:58 PM »
        Quote
        So you can, I now see. I was always taught that self-modifying code is a bad idea, however.

        Amen ;) Debugging such a beast can be a nightmare. Just because you can do something is no reason....

        I'm still trying to figure out what the OP meant by if the ms-dos is exit ???
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        Dias de verano

        • Guest
        Re: if exit..
        « Reply #9 on: March 20, 2008, 01:28:13 PM »
        And somebody else needs to look up the label command...

        Aegis



          Expert

          Thanked: 67
          • Yes
          • Yes
          • Brian's Mess Of A Web Page
        • Experience: Experienced
        • OS: Windows 10
        Re: if exit..
        « Reply #10 on: March 20, 2008, 02:48:16 PM »
        Quote
        the word 'sure' is spelt thus.

        Thus Spake Zarathrustra


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

        Dias de verano

        • Guest
        Re: if exit..
        « Reply #11 on: March 20, 2008, 02:54:57 PM »
        Quote
        the word 'sure' is spelt thus.

        Thus Spake Zarathrustra


        Thus Spoke Z a r a t h u s t r a  (German: Also sprach Zarathustra, sometimes translated Thus Spake Zarathustra), subtitled A Book for All and None (Ein Buch für Alle und Keinen), is a work by German philosopher Friedrich Nietzsche, composed in four parts between 1883 and 1885. It famously declares that "God is dead", elaborates Nietzsche's conception of the will to power, and serves as an introduction to his doctrine of eternal return.

        Described by Nietzsche himself as "the deepest ever written", the book is a dense and esoteric treatise on philosophy and morality, featuring as protagonist a fictionalized Zarathustra. The text encompasses passages of poetry and song, often mocking Judaeo-Christian morality and tradition.

        11victory11

          Topic Starter


          Rookie

          Re: if exit..
          « Reply #12 on: March 20, 2008, 03:11:07 PM »
          well what i guess what im trina do is something like this .,.its not correct because i dont know what to do

          if %var% equ 0 set one=I like it cause of that to.
          if %var% equ 1 set one=eww, are you sure?
          if %var% equ 2 set one=Wow, never thought of that.
          if %var% equ 3 set one=Are you sure?
          echo %one%
          if if %var% equ 1 set one=eww, are you sure? goto h

          :h
          why do you think this?
          set /p choice=



          so like i want it that if the choice of if %var% equ 1 set one=eww, are you shurr? is picked i want that one to go to h and just that one.

          how do i do that
          « Last Edit: March 20, 2008, 04:51:14 PM by 11victory11 »

          Dias de verano

          • Guest
          Re: if exit..
          « Reply #13 on: March 20, 2008, 03:18:11 PM »

          if %var% equ 0 set one=I like it cause of that to.
          if %var% equ 1 set one=eww, are you shurr?
          if %var% equ 2 set one=Wow, never thought of that.
          if %var% equ 3 set one=Are you shurr?
          echo %one%
          if if %var% equ 1 set one=eww, are you shurr? & goto h
          goto skip

          :h
          why do you think this?
          set /p choice=

          :skip

          macdad-



            Expert

            Thanked: 40
            Re: if exit..
            « Reply #14 on: March 20, 2008, 03:21:42 PM »
            correct
            If you dont know DOS, you dont know Windows...

            Thats why Bill Gates created the Windows NT Family.

            11victory11

              Topic Starter


              Rookie

              Re: if exit..
              « Reply #15 on: March 20, 2008, 04:06:27 PM »
              what that didn't work for me , when it got to the random part it just crashes on me.

              Dias de verano

              • Guest
              Re: if exit..
              « Reply #16 on: March 20, 2008, 04:35:41 PM »
              what that didn't work for me , when it got to the random part it just crashes on me.


              Code: [Select]
              set /a var=%random% %%4
                                 ^
                                 ^
                                 ^
                 needs a space here





              11victory11

                Topic Starter


                Rookie

                Re: if exit..
                « Reply #17 on: March 20, 2008, 04:43:11 PM »
                didn't work for me.

                Dias de verano

                • Guest
                Re: if exit..
                « Reply #18 on: March 20, 2008, 04:44:55 PM »
                What happened? You need to tell us more. Just saying "it didn't work" is not good enough if you want us to help you.

                By the way, could you spell 'sure' properly please?

                11victory11

                  Topic Starter


                  Rookie

                  Re: if exit..
                  « Reply #19 on: March 20, 2008, 04:49:28 PM »
                  What happened? You need to tell us more. Just saying "it didn't work" is not good enough if you want us to help you.

                  By the way, could you spell 'sure' properly please?

                  the batch file just exits , the code you gave me didn't work.

                  Sidewinder



                    Guru

                    Thanked: 139
                  • Experience: Familiar
                  • OS: Windows 10
                  Re: if exit..
                  « Reply #20 on: March 20, 2008, 05:32:10 PM »
                  Are you running this batch file from the command prompt or are you double clicking it from Explorer? Until you have debugged your file, you should run from the command line so you can see how your code behaves.

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

                  -- Albert Einstein

                  11victory11

                    Topic Starter


                    Rookie

                    Re: if exit..
                    « Reply #21 on: March 20, 2008, 06:15:36 PM »
                    i fixed it i had some problems with the goto stuff but its fixed now thanks for all the help really need it! ;D ;D ;D
                    « Last Edit: March 20, 2008, 06:30:53 PM by 11victory11 »