tag:blogger.com,1999:blog-6454686814995217416.post4365974120273074784..comments2023-02-28T05:43:34.736-08:00Comments on Batcheero: Function Call In BatchArif Sukocohttp://www.blogger.com/profile/02253016747219807790noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-6454686814995217416.post-21682834414944363212009-03-01T17:16:00.000-08:002009-03-01T17:16:00.000-08:00Hi Arif!As this does not return a value, I'd call ...Hi Arif!<BR/><BR/>As this does not <A HREF="http://batcheero.blogspot.com/2008/01/out-parameter-in-function-call.html" REL="nofollow">return a value</A>, I'd call it a procedure call rather than a function call (both being method calls).<BR/><BR/><BR/>On another note, thanks for the nice, useful blog! :-)blognosehttps://www.blogger.com/profile/17177402935601161687noreply@blogger.comtag:blogger.com,1999:blog-6454686814995217416.post-59554184805930526872009-02-26T14:32:00.000-08:002009-02-26T14:32:00.000-08:00Even if you don't have the call :LABEL syntax intr...Even if you don't have the call :LABEL syntax introduced in Windows NT/XP, you can do much the same thing by calling %0:<BR/><BR/><B>@echo off<BR/>goto :$%1<BR/><BR/>:$<BR/>:: ... main code ...<BR/>call %0 sub1<BR/>:: ... some more code ...<BR/>goto :eof<BR/><BR/>:$sub1<BR/>:: ... sub1 code ...<BR/>:: further arguments start with %2<BR/>goto :eof<BR/><BR/>:eof</B><BR/><BR/>Here I've picked $ as a sigil marking subroutine labels. It's unfortunate that old command processors will ignore label contents past the 8th character, so since $ takes one, you need to make your subroutine labels 7-character unique.<BR/><BR/>This is a great way to make multi-purpose scripts; you can call a specific subroutine directly from the commandline! You should also probably make the default :$ routine print a listing of the available routines.<BR/><BR/>This trick will work so long as you don't <B>cd</B> somewhere else, as %0 could be relative. Of course, you could use %~dpf0, but if you have the new extensions, you might as well use <B>call :LABEL</B>. :)Unknownhttps://www.blogger.com/profile/05423466002788031695noreply@blogger.com