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

Author Topic: Program not working!  (Read 8088 times)

0 Members and 1 Guest are viewing this topic.

BatchFileCommand

    Topic Starter


    Hopeful
  • Thanked: 1
    Program not working!
    « on: January 14, 2009, 08:04:32 PM »
    I'm making this one program called hyperfolders for folders. Well, every time I open it it just displays the text of the file (but in the batch file interface) and then exits out. I have tried anything. After I open it about 6 times it creates a text file with nothing in it called nulgoto. Here's the beggining code. If you find any errors in it tell me.

    Code: [Select]
    @echo off
    title HyperFolder SuperSpeed

    :defaultcolor
    color 48
    goto start

    :blueyellow
    color 16
    goto start

    :bluegreen
    color 12
    goto start

    :blacklightgreen
    color 0a
    goto start

    :blackgray
    color 08
    goto start

    :blackwhite
    color 17
    goto start


    :start
    cls
    echo Welcome to HyperFolder SuperSpeed
    echo ----------------------------------
    echo 1) Create a folder(s)
    echo.
    echo 2) Delete a folder
    echo.
    echo 3) Rename a folder
    echo.
    echo 4) Clear a folder tree
    echo.
    echo 5) Create a folder tree(s)
    echo.
    echo 6) Find a folder (Minimum sweep)
    echo.
    echo 7) Find a folder (System sweep)
    echo.
    echo 8) Compare two folders
    echo.
    echo 9) Move a folder(s) into another
    echo.
    echo 10) Copy folder(s)
    echo.
    echo 11) extras
    echo.
    echo 12) Uninstall
    echo ----------------------------------
    set /p mainmenu=Please choose one:
    if "%mainmenu%"=="1" goto mkdir
    if "%mainmenu%"=="2" goto deldir
    if "%mainmenu%"=="3" goto rendir
    if "%mainmenu%"=="4" goto cleartree
    if "%mainmenu%"=="5" goto mktree
    if "%mainmenu%"=="6" goto folderexist
    if "%mainmenu%"=="7" goto sfe
    if "%mainmenu%"=="8" goto fc
    if "%mainmenu%"=="9" goto fmna
    if "%mainmenu%"=="10" goto xpyf
    if "%mainmenu%"=="11" goto extras
    if "%mainmenu%"=="12" goto uninstall


    Would there be anything in there that would cause it to it. I'm using notepad++ and I checked to make sure there weren't more then 1 sections of one kind and there weren't any variables with the same names whole 9 yards. This is what I get for not having a backup code.
    οτη άβγαλτος μεταφ βαθμολογία

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Program not working!
    « Reply #1 on: January 15, 2009, 04:32:00 AM »
    The code you gave us works in it's entirety, but where are the tags after a selection is made?

    Also, you have many color schemes in the beginning of the code, but only :defaultcolor gets executed before executing an unconditional goto start. Ask yourself how :blueyellow gets executed.

    Need more info.  8)

    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    BatchFileCommand

      Topic Starter


      Hopeful
    • Thanked: 1
      Re: Program not working!
      « Reply #2 on: January 15, 2009, 03:48:18 PM »
      For the color tags, the user has the option of changing the color. If he selects a color it will go to that tag. Then it activates the color then goes to start. I only needed to know if the the code there was fine. Just to make sure that anything in the beginning of the program was messing it up. I wouldn't want to post the whole program. It would be a couple pages worth. Besides, wouldn't want any pass-alongs to copy the code and edit it to claim it as there own. But, would you know any cause that creates a nulgoto file. I may be able to find where I made that mistake.
      οτη άβγαλτος μεταφ βαθμολογία

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Program not working!
      « Reply #3 on: January 15, 2009, 04:28:30 PM »
      As mentioned, the code you posted is fine. Try bringing up your code in an editor and doing a "find" for nulgoto. Could be a typo, however nul and goto are rarely seen in the same instruction.

      If your results are a nulgoto file name, try looking for redirection, as this is the only way for batch code to output to a file.

      Quote
      For the color tags, the user has the option of changing the color. If he selects a color it will go to that tag. Then it activates the color then goes to start

      Fair enough. Do not see that logic in the posted code though.

      Quote
      Besides, wouldn't want any pass-alongs to copy the code and edit it to claim it as there own

      It is rare that any two users would have the exact specifications. I would think most passs-alongs might use your code as a blueprint for their own solution. After all with only 15 or so batch instructions, most batch files follow a familiar pattern.

       8)

      In the future, try writing code in logically complete segments. As each segment is completed, you can test your code before moving on.
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      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: Program not working!
      « Reply #4 on: January 15, 2009, 04:45:46 PM »
      Quote
      Besides, wouldn't want any pass-alongs to copy the code and edit it to claim it as there own

      that's a pushing a bit. almost as if your saying it's worth copying. true, it performs some useful stuff... but what does it do that other programs or the operating system can't?

      As such, it is a great programming exercise (much like my first VB program.. I didn't seem to think so at the time, though...), but it is of limited value to both average users and those familiar with the command prompt.
      I was trying to dereference Null Pointers before it was cool.

      BatchFileCommand

        Topic Starter


        Hopeful
      • Thanked: 1
        Re: Program not working!
        « Reply #5 on: January 15, 2009, 05:01:03 PM »

        Quote
        In the future, try writing code in logically complete segments. As each segment is completed, you can test your code before moving on.


        What do you mean?

        Okay, yeah, I probably was exaggerating a bit about someone stealing the code.
        οτη άβγαλτος μεταφ βαθμολογία

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: Program not working!
        « Reply #6 on: January 15, 2009, 05:31:38 PM »
        Quote
        What do you mean?

        What do you mean what do I mean?  ;D

        Quote
        I wouldn't want to post the whole program. It would be a couple pages worth

        I mean don't write two pages worth of code and then start testing. Well OK, you can, but it's easier to pinpoint both logical and syntax errors with a smaller amount of code.

        For instance, on the code you posted, you could have written the menu first and made sure it appears as planned. Next you would check out all the selection numbers and the validity of the goto tags. Only then would you add the color schemes and the logic to have them execute, testing after you wrote each block of code.

        Bottom line: Keep It Simple

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

        -- Albert Einstein

        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: Program not working!
        « Reply #7 on: January 15, 2009, 05:32:54 PM »
        modular programming.
        I was trying to dereference Null Pointers before it was cool.

        BatchFileCommand

          Topic Starter


          Hopeful
        • Thanked: 1
          Re: Program not working!
          « Reply #8 on: January 15, 2009, 07:32:13 PM »
          Quote
          For instance, on the code you posted, you could have written the menu first and made sure it appears as planned. Next you would check out all the selection numbers and the validity of the goto tags.

          You don't seem to know whats happening. The program is already very big and large. I don't think I could check it because..... Well..... By that time I could've already solved the problem.
          οτη άβγαλτος μεταφ βαθμολογία

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: Program not working!
          « Reply #9 on: January 16, 2009, 04:02:19 AM »
          Quote
          You don't seem to know whats happening. The program is already very big and large.

          I know exactly what is happening. You have this monstrous chunk of code that you're having trouble debugging.

          Did you bring up the code in an editor and search for nulgoto? What were the results? Batch instructions require parameters to do their job, nulgoto is not some default value for file names. Try turning echo on, the resulting console list may give you a hint as to where in the code the error is. If nothing else it should show you how the code runs.
           
          If you choose not to post your code there is not much we can do except suggest the standard ways of debugging a batch file.

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

          -- Albert Einstein

          BatchFileCommand

            Topic Starter


            Hopeful
          • Thanked: 1
            Re: Program not working!
            « Reply #10 on: January 17, 2009, 01:18:45 PM »
            The program executes then exits a milli-second later.
            I could copy the programming and start tearing it apart until it decides to work ::) .
            οτη άβγαλτος μεταφ βαθμολογία

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: Program not working!
            « Reply #11 on: January 17, 2009, 01:50:14 PM »
            You still haven't told us what you've done to debug your code.

            Did you find out how a file got labeled nulgoto? Did you turn echo on and follow the code flow?

            Quote
            I could copy the programming and start tearing it apart until it decides to work

            That's a very real possibility. ;D

            The true sign of intelligence is not knowledge but imagination.

            -- Albert Einstein

            Dias de verano

            • Guest
            Re: Program not working!
            « Reply #12 on: January 17, 2009, 02:00:30 PM »
            wouldn't want any pass-alongs to copy the code and edit it to claim it as there own.

            Ha ha ha that's funny  :D

            patio

            • Moderator


            • Genius
            • Maud' Dib
            • Thanked: 1769
              • Yes
            • Experience: Beginner
            • OS: Windows 7
            Re: Program not working!
            « Reply #13 on: January 17, 2009, 02:04:14 PM »
            If you are worried about people stealing your ideas and making millions off of it you have a ways to go...
            " Anyone who goes to a psychiatrist should have his head examined. "

            Dias de verano

            • Guest
            Re: Program not working!
            « Reply #14 on: January 17, 2009, 02:21:18 PM »
            Missing or inconsistently spelled labels will make a batch bomb out as soon as it starts. There sure are a lot of labels! That is a sign of beginner's code. What I mean is if you have a line saying

            goto xyzq

            and there is no label with that name, either because you left it out or deleted the section of code that contained it, or you spelled it xyqz, what happens is that at runtime, cmd.exe reads the batch, cannot find the label, and quits immediately without even trying to execute the code.

            Problems of this sort are made hard to find if you run batch files by double clicking them in Windows Explorer. The command window closes without you being able to see any error messages. To debug code you need to open a command window in the folder where the batch is, and run it by typing the batch name & pressing Enter. At least that way when it bombs out back to the prompt you stand a chance of seeing any error messages it generated.