Loading ...
Sorry, an error occurred while loading the content.

Help on subprocedures

Expand Messages
  • steven_battisti
    Hello all, A relative batch newbie here. I ve been scouring the web for hours now looking to a concise answer to my question, but of course no luck. I m
    Message 1 of 1 , Mar 5 12:41 PM
    • 0 Attachment
      Hello all,

      A relative batch newbie here. I've been scouring the web for hours
      now looking to a concise answer to my question, but of course no luck.

      I'm writing a relatively simple batch (or so I thought) that is
      divided into a few subprocedures. However, I must be fundamentally
      misunderstanding how it loops through, because my program keeps
      starting over when it is done.

      I'm using the tried-and-true methodology of "snipping all of my code
      from examples on the web". (^_-)

      So, I have 3 questions:

      1. Most of the things I have seen include these two lines:
      if not exist %0 goto ERROR
      if not "%1"=="" goto %1

      I just don't "get" these two lines. Could someone explain what that %
      0 means?

      2. What is the difference between "calling" a procedure and "goto"?

      3. One example I saw looked like this (courtesy Eric Phelps):

      :MAIN
      call %0 ECHOHI
      call %0 ECHOBYE
      goto DONE

      :ECHOHI
      echo Hi!
      goto DONE

      :ECHOBYE
      echo Bye!
      goto DONE

      :ERROR
      echo Error!
      goto DONE

      :DONE
      pause

      What I don't get is, it calls ECHOHI, which prints "Hi" then goes to
      the DONE procedure. So, how does it get back up to the MAIN procedure
      again? How can I just tell the program "you are totally done, quit
      now"?

      Anyway, thanks for your help!

      Steve Battisti
    Your message has been successfully submitted and would be delivered to recipients shortly.