0phoi5 Posted January 12, 2016 Posted January 12, 2016 Hi all, I'm using... @echo off echo Calling a subroutine. gosub subr1 echo Returned from the subroutine. Pause :subr1 echo In the subroutine. return ... but I get ... Calling a subroutine 'gosub' is not recognized as an internal or external command, operable program of batch file [etc.] Is this a CMD version issue? Why isn't GOSUB recognised? Thanks. Quote
White Light Posted January 13, 2016 Posted January 13, 2016 Gosub is not a command. It's call There is also no "return", though the closest is goto :eof Your code would be as follows: @echo off echo Calling a subroutine. call :subr1 rem The : is required when calling a subroutine. echo Returned from the subroutine. pause :subr1 echo In the subroutine. goto :eof rem goto :eof is not needed here as it would already be at the end of the file. Subroutines will run the code all the way to the end of the file, so this just jumps to the end. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.