1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

INCLUDE statement

Discussion in 'Suggestions' started by mrrd, Jul 29, 2010.

  1. mrrd

    Joined:
    Jun 8, 2010
    Messages:
    4
    Likes Received:
    0
    Add an include statement.
    This will work similar to the include statement found in c++.
    ie INCLUDE "c:\Library\subs.btm"
    The include command tells tcc to treat the contents of a specified file as if those contents had appeared in the source batch at the point where the include appears. This will allow for better code re-use and the ON ERROR statement will be active for the included file without breaking cmd compatibility
     
  2. Joe Caverly

    Joined:
    Aug 28, 2009
    Messages:
    638
    Likes Received:
    6
    Hi,
    At present, you can do the following;

    Code:
    gosub "c:\library\subs.btm" MyLabel [%1 %2  %3]
    
    This allows re-use of routines among various batch files. Is this similar to what you would like to do?

    Joe
     
  3. mrrd

    Joined:
    Jun 8, 2010
    Messages:
    4
    Likes Received:
    0
    Yes that's the intent, but using the gosub .... keeps me from having a common error handler in the main.btm. If an error is generated in the subroutine it is not handled by the main error handler

    This I believe will solve the problem that I posted subj "ON ERRORLEVEL not being trapped" on 2010-06-10
     
  4. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    | Yes that's the intent, but using the gosub .... keeps me from having
    | a common error handler in the main.btm. If an error is generated in
    | the subroutine it is not handled by the main error handler
    |
    | This I believe will solve the problem that I posted subj "ON
    | ERRORLEVEL not being trapped" on 2010-06-10

    Instead of a new command, there could be a new option for GOSUB, e.g.,
    /O, to mean "propagate all ON states of the caller", which would mean, among
    others, that ON ERROR or ON ERRORMSG in the called routine would perform
    whatever commands the caller specified. If those commands include continuing
    the interrupted program (batch file), the control would revert to the called
    routine (the normal behavior of ON).
    --
    Steve
     
  5. mrrd

    Joined:
    Jun 8, 2010
    Messages:
    4
    Likes Received:
    0
    I'll go for that
     

Share This Page